
obj/user/primespipe.debug:     file format elf32-i386


Disassembly of section .text:

00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
	// See if we were started with arguments on the stack
	cmpl $USTACKTOP, %esp
  800020:	81 fc 00 e0 bf ee    	cmp    $0xeebfe000,%esp
	jne args_exist
  800026:	75 04                	jne    80002c <args_exist>

	// If not, push dummy argc/argv arguments.
	// This happens when we are loaded by the kernel,
	// because the kernel does not know about passing arguments.
	pushl $0
  800028:	6a 00                	push   $0x0
	pushl $0
  80002a:	6a 00                	push   $0x0

0080002c <args_exist>:

args_exist:
	call libmain
  80002c:	e8 08 02 00 00       	call   800239 <libmain>
1:	jmp 1b
  800031:	eb fe                	jmp    800031 <args_exist+0x5>

00800033 <primeproc>:

#include <inc/lib.h>

unsigned
primeproc(int fd)
{
  800033:	f3 0f 1e fb          	endbr32 
  800037:	55                   	push   %ebp
  800038:	89 e5                	mov    %esp,%ebp
  80003a:	57                   	push   %edi
  80003b:	56                   	push   %esi
  80003c:	53                   	push   %ebx
  80003d:	83 ec 1c             	sub    $0x1c,%esp
  800040:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int i, id, p, pfd[2], wfd, r;

	// fetch a prime from our left neighbor
top:
	if ((r = readn(fd, &p, 4)) != 4)
  800043:	8d 75 e0             	lea    -0x20(%ebp),%esi
		panic("primeproc could not read initial prime: %d, %e", r, r >= 0 ? 0 : r);

	cprintf("%d\n", p);

	// fork a right neighbor to continue the chain
	if ((i=pipe(pfd)) < 0)
  800046:	8d 7d d8             	lea    -0x28(%ebp),%edi
  800049:	eb 5e                	jmp    8000a9 <primeproc+0x76>
		panic("primeproc could not read initial prime: %d, %e", r, r >= 0 ? 0 : r);
  80004b:	83 ec 0c             	sub    $0xc,%esp
  80004e:	85 c0                	test   %eax,%eax
  800050:	ba 00 00 00 00       	mov    $0x0,%edx
  800055:	0f 4e d0             	cmovle %eax,%edx
  800058:	52                   	push   %edx
  800059:	50                   	push   %eax
  80005a:	68 a0 24 80 00       	push   $0x8024a0
  80005f:	6a 15                	push   $0x15
  800061:	68 cf 24 80 00       	push   $0x8024cf
  800066:	e8 40 02 00 00       	call   8002ab <_panic>
		panic("pipe: %e", i);
  80006b:	50                   	push   %eax
  80006c:	68 e5 24 80 00       	push   $0x8024e5
  800071:	6a 1b                	push   $0x1b
  800073:	68 cf 24 80 00       	push   $0x8024cf
  800078:	e8 2e 02 00 00       	call   8002ab <_panic>
	if ((id = fork()) < 0)
		panic("fork: %e", id);
  80007d:	50                   	push   %eax
  80007e:	68 ee 24 80 00       	push   $0x8024ee
  800083:	6a 1d                	push   $0x1d
  800085:	68 cf 24 80 00       	push   $0x8024cf
  80008a:	e8 1c 02 00 00       	call   8002ab <_panic>
	if (id == 0) {
		close(fd);
  80008f:	83 ec 0c             	sub    $0xc,%esp
  800092:	53                   	push   %ebx
  800093:	e8 25 14 00 00       	call   8014bd <close>
		close(pfd[1]);
  800098:	83 c4 04             	add    $0x4,%esp
  80009b:	ff 75 dc             	pushl  -0x24(%ebp)
  80009e:	e8 1a 14 00 00       	call   8014bd <close>
		fd = pfd[0];
  8000a3:	8b 5d d8             	mov    -0x28(%ebp),%ebx
		goto top;
  8000a6:	83 c4 10             	add    $0x10,%esp
	if ((r = readn(fd, &p, 4)) != 4)
  8000a9:	83 ec 04             	sub    $0x4,%esp
  8000ac:	6a 04                	push   $0x4
  8000ae:	56                   	push   %esi
  8000af:	53                   	push   %ebx
  8000b0:	e8 dd 15 00 00       	call   801692 <readn>
  8000b5:	83 c4 10             	add    $0x10,%esp
  8000b8:	83 f8 04             	cmp    $0x4,%eax
  8000bb:	75 8e                	jne    80004b <primeproc+0x18>
	cprintf("%d\n", p);
  8000bd:	83 ec 08             	sub    $0x8,%esp
  8000c0:	ff 75 e0             	pushl  -0x20(%ebp)
  8000c3:	68 e1 24 80 00       	push   $0x8024e1
  8000c8:	e8 c5 02 00 00       	call   800392 <cprintf>
	if ((i=pipe(pfd)) < 0)
  8000cd:	89 3c 24             	mov    %edi,(%esp)
  8000d0:	e8 55 1c 00 00       	call   801d2a <pipe>
  8000d5:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  8000d8:	83 c4 10             	add    $0x10,%esp
  8000db:	85 c0                	test   %eax,%eax
  8000dd:	78 8c                	js     80006b <primeproc+0x38>
	if ((id = fork()) < 0)
  8000df:	e8 00 10 00 00       	call   8010e4 <fork>
  8000e4:	85 c0                	test   %eax,%eax
  8000e6:	78 95                	js     80007d <primeproc+0x4a>
	if (id == 0) {
  8000e8:	74 a5                	je     80008f <primeproc+0x5c>
	}

	close(pfd[0]);
  8000ea:	83 ec 0c             	sub    $0xc,%esp
  8000ed:	ff 75 d8             	pushl  -0x28(%ebp)
  8000f0:	e8 c8 13 00 00       	call   8014bd <close>
	wfd = pfd[1];
  8000f5:	8b 7d dc             	mov    -0x24(%ebp),%edi
  8000f8:	83 c4 10             	add    $0x10,%esp

	// filter out multiples of our prime
	for (;;) {
		if ((r=readn(fd, &i, 4)) != 4)
  8000fb:	8d 75 e4             	lea    -0x1c(%ebp),%esi
  8000fe:	83 ec 04             	sub    $0x4,%esp
  800101:	6a 04                	push   $0x4
  800103:	56                   	push   %esi
  800104:	53                   	push   %ebx
  800105:	e8 88 15 00 00       	call   801692 <readn>
  80010a:	83 c4 10             	add    $0x10,%esp
  80010d:	83 f8 04             	cmp    $0x4,%eax
  800110:	75 42                	jne    800154 <primeproc+0x121>
			panic("primeproc %d readn %d %d %e", p, fd, r, r >= 0 ? 0 : r);
		if (i%p)
  800112:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  800115:	99                   	cltd   
  800116:	f7 7d e0             	idivl  -0x20(%ebp)
  800119:	85 d2                	test   %edx,%edx
  80011b:	74 e1                	je     8000fe <primeproc+0xcb>
			if ((r=write(wfd, &i, 4)) != 4)
  80011d:	83 ec 04             	sub    $0x4,%esp
  800120:	6a 04                	push   $0x4
  800122:	56                   	push   %esi
  800123:	57                   	push   %edi
  800124:	e8 b4 15 00 00       	call   8016dd <write>
  800129:	83 c4 10             	add    $0x10,%esp
  80012c:	83 f8 04             	cmp    $0x4,%eax
  80012f:	74 cd                	je     8000fe <primeproc+0xcb>
				panic("primeproc %d write: %d %e", p, r, r >= 0 ? 0 : r);
  800131:	83 ec 08             	sub    $0x8,%esp
  800134:	85 c0                	test   %eax,%eax
  800136:	ba 00 00 00 00       	mov    $0x0,%edx
  80013b:	0f 4e d0             	cmovle %eax,%edx
  80013e:	52                   	push   %edx
  80013f:	50                   	push   %eax
  800140:	ff 75 e0             	pushl  -0x20(%ebp)
  800143:	68 13 25 80 00       	push   $0x802513
  800148:	6a 2e                	push   $0x2e
  80014a:	68 cf 24 80 00       	push   $0x8024cf
  80014f:	e8 57 01 00 00       	call   8002ab <_panic>
			panic("primeproc %d readn %d %d %e", p, fd, r, r >= 0 ? 0 : r);
  800154:	83 ec 04             	sub    $0x4,%esp
  800157:	85 c0                	test   %eax,%eax
  800159:	ba 00 00 00 00       	mov    $0x0,%edx
  80015e:	0f 4e d0             	cmovle %eax,%edx
  800161:	52                   	push   %edx
  800162:	50                   	push   %eax
  800163:	53                   	push   %ebx
  800164:	ff 75 e0             	pushl  -0x20(%ebp)
  800167:	68 f7 24 80 00       	push   $0x8024f7
  80016c:	6a 2b                	push   $0x2b
  80016e:	68 cf 24 80 00       	push   $0x8024cf
  800173:	e8 33 01 00 00       	call   8002ab <_panic>

00800178 <umain>:
	}
}

void
umain(int argc, char **argv)
{
  800178:	f3 0f 1e fb          	endbr32 
  80017c:	55                   	push   %ebp
  80017d:	89 e5                	mov    %esp,%ebp
  80017f:	53                   	push   %ebx
  800180:	83 ec 20             	sub    $0x20,%esp
	int i, id, p[2], r;

	binaryname = "primespipe";
  800183:	c7 05 00 30 80 00 2d 	movl   $0x80252d,0x803000
  80018a:	25 80 00 

	if ((i=pipe(p)) < 0)
  80018d:	8d 45 ec             	lea    -0x14(%ebp),%eax
  800190:	50                   	push   %eax
  800191:	e8 94 1b 00 00       	call   801d2a <pipe>
  800196:	89 45 f4             	mov    %eax,-0xc(%ebp)
  800199:	83 c4 10             	add    $0x10,%esp
  80019c:	85 c0                	test   %eax,%eax
  80019e:	78 21                	js     8001c1 <umain+0x49>
		panic("pipe: %e", i);

	// fork the first prime process in the chain
	if ((id=fork()) < 0)
  8001a0:	e8 3f 0f 00 00       	call   8010e4 <fork>
  8001a5:	85 c0                	test   %eax,%eax
  8001a7:	78 2a                	js     8001d3 <umain+0x5b>
		panic("fork: %e", id);

	if (id == 0) {
  8001a9:	75 3a                	jne    8001e5 <umain+0x6d>
		close(p[1]);
  8001ab:	83 ec 0c             	sub    $0xc,%esp
  8001ae:	ff 75 f0             	pushl  -0x10(%ebp)
  8001b1:	e8 07 13 00 00       	call   8014bd <close>
		primeproc(p[0]);
  8001b6:	83 c4 04             	add    $0x4,%esp
  8001b9:	ff 75 ec             	pushl  -0x14(%ebp)
  8001bc:	e8 72 fe ff ff       	call   800033 <primeproc>
		panic("pipe: %e", i);
  8001c1:	50                   	push   %eax
  8001c2:	68 e5 24 80 00       	push   $0x8024e5
  8001c7:	6a 3a                	push   $0x3a
  8001c9:	68 cf 24 80 00       	push   $0x8024cf
  8001ce:	e8 d8 00 00 00       	call   8002ab <_panic>
		panic("fork: %e", id);
  8001d3:	50                   	push   %eax
  8001d4:	68 ee 24 80 00       	push   $0x8024ee
  8001d9:	6a 3e                	push   $0x3e
  8001db:	68 cf 24 80 00       	push   $0x8024cf
  8001e0:	e8 c6 00 00 00       	call   8002ab <_panic>
	}

	close(p[0]);
  8001e5:	83 ec 0c             	sub    $0xc,%esp
  8001e8:	ff 75 ec             	pushl  -0x14(%ebp)
  8001eb:	e8 cd 12 00 00       	call   8014bd <close>

	// feed all the integers through
	for (i=2;; i++)
  8001f0:	c7 45 f4 02 00 00 00 	movl   $0x2,-0xc(%ebp)
  8001f7:	83 c4 10             	add    $0x10,%esp
		if ((r=write(p[1], &i, 4)) != 4)
  8001fa:	8d 5d f4             	lea    -0xc(%ebp),%ebx
  8001fd:	83 ec 04             	sub    $0x4,%esp
  800200:	6a 04                	push   $0x4
  800202:	53                   	push   %ebx
  800203:	ff 75 f0             	pushl  -0x10(%ebp)
  800206:	e8 d2 14 00 00       	call   8016dd <write>
  80020b:	83 c4 10             	add    $0x10,%esp
  80020e:	83 f8 04             	cmp    $0x4,%eax
  800211:	75 06                	jne    800219 <umain+0xa1>
	for (i=2;; i++)
  800213:	83 45 f4 01          	addl   $0x1,-0xc(%ebp)
		if ((r=write(p[1], &i, 4)) != 4)
  800217:	eb e4                	jmp    8001fd <umain+0x85>
			panic("generator write: %d, %e", r, r >= 0 ? 0 : r);
  800219:	83 ec 0c             	sub    $0xc,%esp
  80021c:	85 c0                	test   %eax,%eax
  80021e:	ba 00 00 00 00       	mov    $0x0,%edx
  800223:	0f 4e d0             	cmovle %eax,%edx
  800226:	52                   	push   %edx
  800227:	50                   	push   %eax
  800228:	68 38 25 80 00       	push   $0x802538
  80022d:	6a 4a                	push   $0x4a
  80022f:	68 cf 24 80 00       	push   $0x8024cf
  800234:	e8 72 00 00 00       	call   8002ab <_panic>

00800239 <libmain>:
const volatile struct Env *thisenv;
const char *binaryname = "<unknown>";

void
libmain(int argc, char **argv)
{
  800239:	f3 0f 1e fb          	endbr32 
  80023d:	55                   	push   %ebp
  80023e:	89 e5                	mov    %esp,%ebp
  800240:	56                   	push   %esi
  800241:	53                   	push   %ebx
  800242:	8b 5d 08             	mov    0x8(%ebp),%ebx
  800245:	8b 75 0c             	mov    0xc(%ebp),%esi
	;    //系统调用，我们已经在Exercise 7中实现了
	
	
	
	//屏幕上打印出来了字母，但后续报错了，有意思，让我看看问题出现在哪。
	thisenv=0;
  800248:	c7 05 04 40 80 00 00 	movl   $0x0,0x804004
  80024f:	00 00 00 
	thisenv = &envs[ENVX(sys_getenvid())];      //获取Env结构指针
  800252:	e8 10 0b 00 00       	call   800d67 <sys_getenvid>
  800257:	25 ff 03 00 00       	and    $0x3ff,%eax
  80025c:	6b c0 7c             	imul   $0x7c,%eax,%eax
  80025f:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  800264:	a3 04 40 80 00       	mov    %eax,0x804004

	// save the name of the program so that panic() can use it
	if (argc > 0)
  800269:	85 db                	test   %ebx,%ebx
  80026b:	7e 07                	jle    800274 <libmain+0x3b>
		binaryname = argv[0];
  80026d:	8b 06                	mov    (%esi),%eax
  80026f:	a3 00 30 80 00       	mov    %eax,0x803000

	// call user main routine
	umain(argc, argv);
  800274:	83 ec 08             	sub    $0x8,%esp
  800277:	56                   	push   %esi
  800278:	53                   	push   %ebx
  800279:	e8 fa fe ff ff       	call   800178 <umain>

	// exit gracefully
	exit();
  80027e:	e8 0a 00 00 00       	call   80028d <exit>
}
  800283:	83 c4 10             	add    $0x10,%esp
  800286:	8d 65 f8             	lea    -0x8(%ebp),%esp
  800289:	5b                   	pop    %ebx
  80028a:	5e                   	pop    %esi
  80028b:	5d                   	pop    %ebp
  80028c:	c3                   	ret    

0080028d <exit>:

#include <inc/lib.h>

void
exit(void)
{
  80028d:	f3 0f 1e fb          	endbr32 
  800291:	55                   	push   %ebp
  800292:	89 e5                	mov    %esp,%ebp
  800294:	83 ec 08             	sub    $0x8,%esp
	close_all();
  800297:	e8 52 12 00 00       	call   8014ee <close_all>
	sys_env_destroy(0);
  80029c:	83 ec 0c             	sub    $0xc,%esp
  80029f:	6a 00                	push   $0x0
  8002a1:	e8 7c 0a 00 00       	call   800d22 <sys_env_destroy>
}
  8002a6:	83 c4 10             	add    $0x10,%esp
  8002a9:	c9                   	leave  
  8002aa:	c3                   	ret    

008002ab <_panic>:
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt, ...)
{
  8002ab:	f3 0f 1e fb          	endbr32 
  8002af:	55                   	push   %ebp
  8002b0:	89 e5                	mov    %esp,%ebp
  8002b2:	56                   	push   %esi
  8002b3:	53                   	push   %ebx
	va_list ap;

	va_start(ap, fmt);
  8002b4:	8d 5d 14             	lea    0x14(%ebp),%ebx

	// Print the panic message
	cprintf("[%08x] user panic in %s at %s:%d: ",
  8002b7:	8b 35 00 30 80 00    	mov    0x803000,%esi
  8002bd:	e8 a5 0a 00 00       	call   800d67 <sys_getenvid>
  8002c2:	83 ec 0c             	sub    $0xc,%esp
  8002c5:	ff 75 0c             	pushl  0xc(%ebp)
  8002c8:	ff 75 08             	pushl  0x8(%ebp)
  8002cb:	56                   	push   %esi
  8002cc:	50                   	push   %eax
  8002cd:	68 5c 25 80 00       	push   $0x80255c
  8002d2:	e8 bb 00 00 00       	call   800392 <cprintf>
		sys_getenvid(), binaryname, file, line);
	vcprintf(fmt, ap);
  8002d7:	83 c4 18             	add    $0x18,%esp
  8002da:	53                   	push   %ebx
  8002db:	ff 75 10             	pushl  0x10(%ebp)
  8002de:	e8 5a 00 00 00       	call   80033d <vcprintf>
	cprintf("\n");
  8002e3:	c7 04 24 e3 24 80 00 	movl   $0x8024e3,(%esp)
  8002ea:	e8 a3 00 00 00       	call   800392 <cprintf>
  8002ef:	83 c4 10             	add    $0x10,%esp

	// Cause a breakpoint exception
	while (1)
		asm volatile("int3");
  8002f2:	cc                   	int3   
  8002f3:	eb fd                	jmp    8002f2 <_panic+0x47>

008002f5 <putch>:
};


static void
putch(int ch, struct printbuf *b)
{
  8002f5:	f3 0f 1e fb          	endbr32 
  8002f9:	55                   	push   %ebp
  8002fa:	89 e5                	mov    %esp,%ebp
  8002fc:	53                   	push   %ebx
  8002fd:	83 ec 04             	sub    $0x4,%esp
  800300:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  800303:	8b 13                	mov    (%ebx),%edx
  800305:	8d 42 01             	lea    0x1(%edx),%eax
  800308:	89 03                	mov    %eax,(%ebx)
  80030a:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80030d:	88 4c 13 08          	mov    %cl,0x8(%ebx,%edx,1)
	if (b->idx == 256-1) {
  800311:	3d ff 00 00 00       	cmp    $0xff,%eax
  800316:	74 09                	je     800321 <putch+0x2c>
		sys_cputs(b->buf, b->idx);
		b->idx = 0;
	}
	b->cnt++;
  800318:	83 43 04 01          	addl   $0x1,0x4(%ebx)
}
  80031c:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  80031f:	c9                   	leave  
  800320:	c3                   	ret    
		sys_cputs(b->buf, b->idx);
  800321:	83 ec 08             	sub    $0x8,%esp
  800324:	68 ff 00 00 00       	push   $0xff
  800329:	8d 43 08             	lea    0x8(%ebx),%eax
  80032c:	50                   	push   %eax
  80032d:	e8 ab 09 00 00       	call   800cdd <sys_cputs>
		b->idx = 0;
  800332:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  800338:	83 c4 10             	add    $0x10,%esp
  80033b:	eb db                	jmp    800318 <putch+0x23>

0080033d <vcprintf>:

int
vcprintf(const char *fmt, va_list ap)
{
  80033d:	f3 0f 1e fb          	endbr32 
  800341:	55                   	push   %ebp
  800342:	89 e5                	mov    %esp,%ebp
  800344:	81 ec 18 01 00 00    	sub    $0x118,%esp
	struct printbuf b;

	b.idx = 0;
  80034a:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  800351:	00 00 00 
	b.cnt = 0;
  800354:	c7 85 f4 fe ff ff 00 	movl   $0x0,-0x10c(%ebp)
  80035b:	00 00 00 
	vprintfmt((void*)putch, &b, fmt, ap);
  80035e:	ff 75 0c             	pushl  0xc(%ebp)
  800361:	ff 75 08             	pushl  0x8(%ebp)
  800364:	8d 85 f0 fe ff ff    	lea    -0x110(%ebp),%eax
  80036a:	50                   	push   %eax
  80036b:	68 f5 02 80 00       	push   $0x8002f5
  800370:	e8 20 01 00 00       	call   800495 <vprintfmt>
	sys_cputs(b.buf, b.idx);
  800375:	83 c4 08             	add    $0x8,%esp
  800378:	ff b5 f0 fe ff ff    	pushl  -0x110(%ebp)
  80037e:	8d 85 f8 fe ff ff    	lea    -0x108(%ebp),%eax
  800384:	50                   	push   %eax
  800385:	e8 53 09 00 00       	call   800cdd <sys_cputs>

	return b.cnt;
}
  80038a:	8b 85 f4 fe ff ff    	mov    -0x10c(%ebp),%eax
  800390:	c9                   	leave  
  800391:	c3                   	ret    

00800392 <cprintf>:

int
cprintf(const char *fmt, ...)
{
  800392:	f3 0f 1e fb          	endbr32 
  800396:	55                   	push   %ebp
  800397:	89 e5                	mov    %esp,%ebp
  800399:	83 ec 10             	sub    $0x10,%esp
	va_list ap;
	int cnt;

	va_start(ap, fmt);
  80039c:	8d 45 0c             	lea    0xc(%ebp),%eax
	cnt = vcprintf(fmt, ap);
  80039f:	50                   	push   %eax
  8003a0:	ff 75 08             	pushl  0x8(%ebp)
  8003a3:	e8 95 ff ff ff       	call   80033d <vcprintf>
	va_end(ap);

	return cnt;
}
  8003a8:	c9                   	leave  
  8003a9:	c3                   	ret    

008003aa <printnum>:
 * using specified putch function and associated pointer putdat.
 */
static void
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
  8003aa:	55                   	push   %ebp
  8003ab:	89 e5                	mov    %esp,%ebp
  8003ad:	57                   	push   %edi
  8003ae:	56                   	push   %esi
  8003af:	53                   	push   %ebx
  8003b0:	83 ec 1c             	sub    $0x1c,%esp
  8003b3:	89 c7                	mov    %eax,%edi
  8003b5:	89 d6                	mov    %edx,%esi
  8003b7:	8b 45 08             	mov    0x8(%ebp),%eax
  8003ba:	8b 55 0c             	mov    0xc(%ebp),%edx
  8003bd:	89 d1                	mov    %edx,%ecx
  8003bf:	89 c2                	mov    %eax,%edx
  8003c1:	89 45 d8             	mov    %eax,-0x28(%ebp)
  8003c4:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  8003c7:	8b 45 10             	mov    0x10(%ebp),%eax
  8003ca:	8b 5d 14             	mov    0x14(%ebp),%ebx
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
  8003cd:	89 45 e0             	mov    %eax,-0x20(%ebp)
  8003d0:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  8003d7:	39 c2                	cmp    %eax,%edx
  8003d9:	1b 4d e4             	sbb    -0x1c(%ebp),%ecx
  8003dc:	72 3e                	jb     80041c <printnum+0x72>
		printnum(putch, putdat, num / base, base, width - 1, padc);
  8003de:	83 ec 0c             	sub    $0xc,%esp
  8003e1:	ff 75 18             	pushl  0x18(%ebp)
  8003e4:	83 eb 01             	sub    $0x1,%ebx
  8003e7:	53                   	push   %ebx
  8003e8:	50                   	push   %eax
  8003e9:	83 ec 08             	sub    $0x8,%esp
  8003ec:	ff 75 e4             	pushl  -0x1c(%ebp)
  8003ef:	ff 75 e0             	pushl  -0x20(%ebp)
  8003f2:	ff 75 dc             	pushl  -0x24(%ebp)
  8003f5:	ff 75 d8             	pushl  -0x28(%ebp)
  8003f8:	e8 43 1e 00 00       	call   802240 <__udivdi3>
  8003fd:	83 c4 18             	add    $0x18,%esp
  800400:	52                   	push   %edx
  800401:	50                   	push   %eax
  800402:	89 f2                	mov    %esi,%edx
  800404:	89 f8                	mov    %edi,%eax
  800406:	e8 9f ff ff ff       	call   8003aa <printnum>
  80040b:	83 c4 20             	add    $0x20,%esp
  80040e:	eb 13                	jmp    800423 <printnum+0x79>
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
			putch(padc, putdat);
  800410:	83 ec 08             	sub    $0x8,%esp
  800413:	56                   	push   %esi
  800414:	ff 75 18             	pushl  0x18(%ebp)
  800417:	ff d7                	call   *%edi
  800419:	83 c4 10             	add    $0x10,%esp
		while (--width > 0)
  80041c:	83 eb 01             	sub    $0x1,%ebx
  80041f:	85 db                	test   %ebx,%ebx
  800421:	7f ed                	jg     800410 <printnum+0x66>
	}

	// then print this (the least significant) digit
	putch("0123456789abcdef"[num % base], putdat);
  800423:	83 ec 08             	sub    $0x8,%esp
  800426:	56                   	push   %esi
  800427:	83 ec 04             	sub    $0x4,%esp
  80042a:	ff 75 e4             	pushl  -0x1c(%ebp)
  80042d:	ff 75 e0             	pushl  -0x20(%ebp)
  800430:	ff 75 dc             	pushl  -0x24(%ebp)
  800433:	ff 75 d8             	pushl  -0x28(%ebp)
  800436:	e8 15 1f 00 00       	call   802350 <__umoddi3>
  80043b:	83 c4 14             	add    $0x14,%esp
  80043e:	0f be 80 7f 25 80 00 	movsbl 0x80257f(%eax),%eax
  800445:	50                   	push   %eax
  800446:	ff d7                	call   *%edi
}
  800448:	83 c4 10             	add    $0x10,%esp
  80044b:	8d 65 f4             	lea    -0xc(%ebp),%esp
  80044e:	5b                   	pop    %ebx
  80044f:	5e                   	pop    %esi
  800450:	5f                   	pop    %edi
  800451:	5d                   	pop    %ebp
  800452:	c3                   	ret    

00800453 <sprintputch>:
	int cnt;
};

static void
sprintputch(int ch, struct sprintbuf *b)
{
  800453:	f3 0f 1e fb          	endbr32 
  800457:	55                   	push   %ebp
  800458:	89 e5                	mov    %esp,%ebp
  80045a:	8b 45 0c             	mov    0xc(%ebp),%eax
	b->cnt++;
  80045d:	83 40 08 01          	addl   $0x1,0x8(%eax)
	if (b->buf < b->ebuf)
  800461:	8b 10                	mov    (%eax),%edx
  800463:	3b 50 04             	cmp    0x4(%eax),%edx
  800466:	73 0a                	jae    800472 <sprintputch+0x1f>
		*b->buf++ = ch;
  800468:	8d 4a 01             	lea    0x1(%edx),%ecx
  80046b:	89 08                	mov    %ecx,(%eax)
  80046d:	8b 45 08             	mov    0x8(%ebp),%eax
  800470:	88 02                	mov    %al,(%edx)
}
  800472:	5d                   	pop    %ebp
  800473:	c3                   	ret    

00800474 <printfmt>:
{
  800474:	f3 0f 1e fb          	endbr32 
  800478:	55                   	push   %ebp
  800479:	89 e5                	mov    %esp,%ebp
  80047b:	83 ec 08             	sub    $0x8,%esp
	va_start(ap, fmt);
  80047e:	8d 45 14             	lea    0x14(%ebp),%eax
	vprintfmt(putch, putdat, fmt, ap);
  800481:	50                   	push   %eax
  800482:	ff 75 10             	pushl  0x10(%ebp)
  800485:	ff 75 0c             	pushl  0xc(%ebp)
  800488:	ff 75 08             	pushl  0x8(%ebp)
  80048b:	e8 05 00 00 00       	call   800495 <vprintfmt>
}
  800490:	83 c4 10             	add    $0x10,%esp
  800493:	c9                   	leave  
  800494:	c3                   	ret    

00800495 <vprintfmt>:
{
  800495:	f3 0f 1e fb          	endbr32 
  800499:	55                   	push   %ebp
  80049a:	89 e5                	mov    %esp,%ebp
  80049c:	57                   	push   %edi
  80049d:	56                   	push   %esi
  80049e:	53                   	push   %ebx
  80049f:	83 ec 3c             	sub    $0x3c,%esp
  8004a2:	8b 75 08             	mov    0x8(%ebp),%esi
  8004a5:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  8004a8:	8b 7d 10             	mov    0x10(%ebp),%edi
  8004ab:	e9 5d 03 00 00       	jmp    80080d <vprintfmt+0x378>
		padc = ' ';
  8004b0:	c6 45 d3 20          	movb   $0x20,-0x2d(%ebp)
		altflag = 0;
  8004b4:	c7 45 e0 00 00 00 00 	movl   $0x0,-0x20(%ebp)
		precision = -1;
  8004bb:	c7 45 d8 ff ff ff ff 	movl   $0xffffffff,-0x28(%ebp)
		width = -1;
  8004c2:	c7 45 d4 ff ff ff ff 	movl   $0xffffffff,-0x2c(%ebp)
		lflag = 0;
  8004c9:	b9 00 00 00 00       	mov    $0x0,%ecx
		switch (ch = *(unsigned char *) fmt++) {
  8004ce:	8d 47 01             	lea    0x1(%edi),%eax
  8004d1:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  8004d4:	0f b6 17             	movzbl (%edi),%edx
  8004d7:	8d 42 dd             	lea    -0x23(%edx),%eax
  8004da:	3c 55                	cmp    $0x55,%al
  8004dc:	0f 87 ae 03 00 00    	ja     800890 <vprintfmt+0x3fb>
  8004e2:	0f b6 c0             	movzbl %al,%eax
  8004e5:	3e ff 24 85 c0 26 80 	notrack jmp *0x8026c0(,%eax,4)
  8004ec:	00 
  8004ed:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			padc = '-';
  8004f0:	c6 45 d3 2d          	movb   $0x2d,-0x2d(%ebp)
  8004f4:	eb d8                	jmp    8004ce <vprintfmt+0x39>
		switch (ch = *(unsigned char *) fmt++) {
  8004f6:	8b 7d e4             	mov    -0x1c(%ebp),%edi
  8004f9:	c6 45 d3 30          	movb   $0x30,-0x2d(%ebp)
  8004fd:	eb cf                	jmp    8004ce <vprintfmt+0x39>
  8004ff:	0f b6 d2             	movzbl %dl,%edx
  800502:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			for (precision = 0; ; ++fmt) {
  800505:	b8 00 00 00 00       	mov    $0x0,%eax
  80050a:	89 4d e4             	mov    %ecx,-0x1c(%ebp)
				precision = precision * 10 + ch - '0';
  80050d:	8d 04 80             	lea    (%eax,%eax,4),%eax
  800510:	8d 44 42 d0          	lea    -0x30(%edx,%eax,2),%eax
				ch = *fmt;
  800514:	0f be 17             	movsbl (%edi),%edx
				if (ch < '0' || ch > '9')
  800517:	8d 4a d0             	lea    -0x30(%edx),%ecx
  80051a:	83 f9 09             	cmp    $0x9,%ecx
  80051d:	77 55                	ja     800574 <vprintfmt+0xdf>
			for (precision = 0; ; ++fmt) {
  80051f:	83 c7 01             	add    $0x1,%edi
				precision = precision * 10 + ch - '0';
  800522:	eb e9                	jmp    80050d <vprintfmt+0x78>
			precision = va_arg(ap, int);
  800524:	8b 45 14             	mov    0x14(%ebp),%eax
  800527:	8b 00                	mov    (%eax),%eax
  800529:	89 45 d8             	mov    %eax,-0x28(%ebp)
  80052c:	8b 45 14             	mov    0x14(%ebp),%eax
  80052f:	8d 40 04             	lea    0x4(%eax),%eax
  800532:	89 45 14             	mov    %eax,0x14(%ebp)
		switch (ch = *(unsigned char *) fmt++) {
  800535:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			if (width < 0)
  800538:	83 7d d4 00          	cmpl   $0x0,-0x2c(%ebp)
  80053c:	79 90                	jns    8004ce <vprintfmt+0x39>
				width = precision, precision = -1;
  80053e:	8b 45 d8             	mov    -0x28(%ebp),%eax
  800541:	89 45 d4             	mov    %eax,-0x2c(%ebp)
  800544:	c7 45 d8 ff ff ff ff 	movl   $0xffffffff,-0x28(%ebp)
  80054b:	eb 81                	jmp    8004ce <vprintfmt+0x39>
  80054d:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  800550:	85 c0                	test   %eax,%eax
  800552:	ba 00 00 00 00       	mov    $0x0,%edx
  800557:	0f 49 d0             	cmovns %eax,%edx
  80055a:	89 55 d4             	mov    %edx,-0x2c(%ebp)
		switch (ch = *(unsigned char *) fmt++) {
  80055d:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			goto reswitch;
  800560:	e9 69 ff ff ff       	jmp    8004ce <vprintfmt+0x39>
		switch (ch = *(unsigned char *) fmt++) {
  800565:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			altflag = 1;
  800568:	c7 45 e0 01 00 00 00 	movl   $0x1,-0x20(%ebp)
			goto reswitch;
  80056f:	e9 5a ff ff ff       	jmp    8004ce <vprintfmt+0x39>
  800574:	8b 4d e4             	mov    -0x1c(%ebp),%ecx
  800577:	89 45 d8             	mov    %eax,-0x28(%ebp)
  80057a:	eb bc                	jmp    800538 <vprintfmt+0xa3>
			lflag++;
  80057c:	83 c1 01             	add    $0x1,%ecx
		switch (ch = *(unsigned char *) fmt++) {
  80057f:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			goto reswitch;
  800582:	e9 47 ff ff ff       	jmp    8004ce <vprintfmt+0x39>
			putch(va_arg(ap, int), putdat);
  800587:	8b 45 14             	mov    0x14(%ebp),%eax
  80058a:	8d 78 04             	lea    0x4(%eax),%edi
  80058d:	83 ec 08             	sub    $0x8,%esp
  800590:	53                   	push   %ebx
  800591:	ff 30                	pushl  (%eax)
  800593:	ff d6                	call   *%esi
			break;
  800595:	83 c4 10             	add    $0x10,%esp
			putch(va_arg(ap, int), putdat);
  800598:	89 7d 14             	mov    %edi,0x14(%ebp)
			break;
  80059b:	e9 6a 02 00 00       	jmp    80080a <vprintfmt+0x375>
			err = va_arg(ap, int);
  8005a0:	8b 45 14             	mov    0x14(%ebp),%eax
  8005a3:	8d 78 04             	lea    0x4(%eax),%edi
  8005a6:	8b 00                	mov    (%eax),%eax
  8005a8:	99                   	cltd   
  8005a9:	31 d0                	xor    %edx,%eax
  8005ab:	29 d0                	sub    %edx,%eax
			if (err >= MAXERROR || (p = error_string[err]) == NULL)
  8005ad:	83 f8 0f             	cmp    $0xf,%eax
  8005b0:	7f 23                	jg     8005d5 <vprintfmt+0x140>
  8005b2:	8b 14 85 20 28 80 00 	mov    0x802820(,%eax,4),%edx
  8005b9:	85 d2                	test   %edx,%edx
  8005bb:	74 18                	je     8005d5 <vprintfmt+0x140>
				printfmt(putch, putdat, "%s", p);
  8005bd:	52                   	push   %edx
  8005be:	68 a1 2a 80 00       	push   $0x802aa1
  8005c3:	53                   	push   %ebx
  8005c4:	56                   	push   %esi
  8005c5:	e8 aa fe ff ff       	call   800474 <printfmt>
  8005ca:	83 c4 10             	add    $0x10,%esp
			err = va_arg(ap, int);
  8005cd:	89 7d 14             	mov    %edi,0x14(%ebp)
  8005d0:	e9 35 02 00 00       	jmp    80080a <vprintfmt+0x375>
				printfmt(putch, putdat, "error %d", err);
  8005d5:	50                   	push   %eax
  8005d6:	68 97 25 80 00       	push   $0x802597
  8005db:	53                   	push   %ebx
  8005dc:	56                   	push   %esi
  8005dd:	e8 92 fe ff ff       	call   800474 <printfmt>
  8005e2:	83 c4 10             	add    $0x10,%esp
			err = va_arg(ap, int);
  8005e5:	89 7d 14             	mov    %edi,0x14(%ebp)
				printfmt(putch, putdat, "error %d", err);
  8005e8:	e9 1d 02 00 00       	jmp    80080a <vprintfmt+0x375>
			if ((p = va_arg(ap, char *)) == NULL)
  8005ed:	8b 45 14             	mov    0x14(%ebp),%eax
  8005f0:	83 c0 04             	add    $0x4,%eax
  8005f3:	89 45 c8             	mov    %eax,-0x38(%ebp)
  8005f6:	8b 45 14             	mov    0x14(%ebp),%eax
  8005f9:	8b 10                	mov    (%eax),%edx
				p = "(null)";
  8005fb:	85 d2                	test   %edx,%edx
  8005fd:	b8 90 25 80 00       	mov    $0x802590,%eax
  800602:	0f 45 c2             	cmovne %edx,%eax
  800605:	89 45 cc             	mov    %eax,-0x34(%ebp)
			if (width > 0 && padc != '-')
  800608:	83 7d d4 00          	cmpl   $0x0,-0x2c(%ebp)
  80060c:	7e 06                	jle    800614 <vprintfmt+0x17f>
  80060e:	80 7d d3 2d          	cmpb   $0x2d,-0x2d(%ebp)
  800612:	75 0d                	jne    800621 <vprintfmt+0x18c>
				for (width -= strnlen(p, precision); width > 0; width--)
  800614:	8b 45 cc             	mov    -0x34(%ebp),%eax
  800617:	89 c7                	mov    %eax,%edi
  800619:	03 45 d4             	add    -0x2c(%ebp),%eax
  80061c:	89 45 d4             	mov    %eax,-0x2c(%ebp)
  80061f:	eb 55                	jmp    800676 <vprintfmt+0x1e1>
  800621:	83 ec 08             	sub    $0x8,%esp
  800624:	ff 75 d8             	pushl  -0x28(%ebp)
  800627:	ff 75 cc             	pushl  -0x34(%ebp)
  80062a:	e8 15 03 00 00       	call   800944 <strnlen>
  80062f:	8b 55 d4             	mov    -0x2c(%ebp),%edx
  800632:	29 c2                	sub    %eax,%edx
  800634:	89 55 c4             	mov    %edx,-0x3c(%ebp)
  800637:	83 c4 10             	add    $0x10,%esp
  80063a:	89 d7                	mov    %edx,%edi
					putch(padc, putdat);
  80063c:	0f be 45 d3          	movsbl -0x2d(%ebp),%eax
  800640:	89 45 d4             	mov    %eax,-0x2c(%ebp)
				for (width -= strnlen(p, precision); width > 0; width--)
  800643:	85 ff                	test   %edi,%edi
  800645:	7e 11                	jle    800658 <vprintfmt+0x1c3>
					putch(padc, putdat);
  800647:	83 ec 08             	sub    $0x8,%esp
  80064a:	53                   	push   %ebx
  80064b:	ff 75 d4             	pushl  -0x2c(%ebp)
  80064e:	ff d6                	call   *%esi
				for (width -= strnlen(p, precision); width > 0; width--)
  800650:	83 ef 01             	sub    $0x1,%edi
  800653:	83 c4 10             	add    $0x10,%esp
  800656:	eb eb                	jmp    800643 <vprintfmt+0x1ae>
  800658:	8b 55 c4             	mov    -0x3c(%ebp),%edx
  80065b:	85 d2                	test   %edx,%edx
  80065d:	b8 00 00 00 00       	mov    $0x0,%eax
  800662:	0f 49 c2             	cmovns %edx,%eax
  800665:	29 c2                	sub    %eax,%edx
  800667:	89 55 d4             	mov    %edx,-0x2c(%ebp)
  80066a:	eb a8                	jmp    800614 <vprintfmt+0x17f>
					putch(ch, putdat);
  80066c:	83 ec 08             	sub    $0x8,%esp
  80066f:	53                   	push   %ebx
  800670:	52                   	push   %edx
  800671:	ff d6                	call   *%esi
  800673:	83 c4 10             	add    $0x10,%esp
  800676:	8b 4d d4             	mov    -0x2c(%ebp),%ecx
  800679:	29 f9                	sub    %edi,%ecx
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  80067b:	83 c7 01             	add    $0x1,%edi
  80067e:	0f b6 47 ff          	movzbl -0x1(%edi),%eax
  800682:	0f be d0             	movsbl %al,%edx
  800685:	85 d2                	test   %edx,%edx
  800687:	74 4b                	je     8006d4 <vprintfmt+0x23f>
  800689:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  80068d:	78 06                	js     800695 <vprintfmt+0x200>
  80068f:	83 6d d8 01          	subl   $0x1,-0x28(%ebp)
  800693:	78 1e                	js     8006b3 <vprintfmt+0x21e>
				if (altflag && (ch < ' ' || ch > '~'))
  800695:	83 7d e0 00          	cmpl   $0x0,-0x20(%ebp)
  800699:	74 d1                	je     80066c <vprintfmt+0x1d7>
  80069b:	0f be c0             	movsbl %al,%eax
  80069e:	83 e8 20             	sub    $0x20,%eax
  8006a1:	83 f8 5e             	cmp    $0x5e,%eax
  8006a4:	76 c6                	jbe    80066c <vprintfmt+0x1d7>
					putch('?', putdat);
  8006a6:	83 ec 08             	sub    $0x8,%esp
  8006a9:	53                   	push   %ebx
  8006aa:	6a 3f                	push   $0x3f
  8006ac:	ff d6                	call   *%esi
  8006ae:	83 c4 10             	add    $0x10,%esp
  8006b1:	eb c3                	jmp    800676 <vprintfmt+0x1e1>
  8006b3:	89 cf                	mov    %ecx,%edi
  8006b5:	eb 0e                	jmp    8006c5 <vprintfmt+0x230>
				putch(' ', putdat);
  8006b7:	83 ec 08             	sub    $0x8,%esp
  8006ba:	53                   	push   %ebx
  8006bb:	6a 20                	push   $0x20
  8006bd:	ff d6                	call   *%esi
			for (; width > 0; width--)
  8006bf:	83 ef 01             	sub    $0x1,%edi
  8006c2:	83 c4 10             	add    $0x10,%esp
  8006c5:	85 ff                	test   %edi,%edi
  8006c7:	7f ee                	jg     8006b7 <vprintfmt+0x222>
			if ((p = va_arg(ap, char *)) == NULL)
  8006c9:	8b 45 c8             	mov    -0x38(%ebp),%eax
  8006cc:	89 45 14             	mov    %eax,0x14(%ebp)
  8006cf:	e9 36 01 00 00       	jmp    80080a <vprintfmt+0x375>
  8006d4:	89 cf                	mov    %ecx,%edi
  8006d6:	eb ed                	jmp    8006c5 <vprintfmt+0x230>
	if (lflag >= 2)
  8006d8:	83 f9 01             	cmp    $0x1,%ecx
  8006db:	7f 1f                	jg     8006fc <vprintfmt+0x267>
	else if (lflag)
  8006dd:	85 c9                	test   %ecx,%ecx
  8006df:	74 67                	je     800748 <vprintfmt+0x2b3>
		return va_arg(*ap, long);
  8006e1:	8b 45 14             	mov    0x14(%ebp),%eax
  8006e4:	8b 00                	mov    (%eax),%eax
  8006e6:	89 45 d8             	mov    %eax,-0x28(%ebp)
  8006e9:	89 c1                	mov    %eax,%ecx
  8006eb:	c1 f9 1f             	sar    $0x1f,%ecx
  8006ee:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  8006f1:	8b 45 14             	mov    0x14(%ebp),%eax
  8006f4:	8d 40 04             	lea    0x4(%eax),%eax
  8006f7:	89 45 14             	mov    %eax,0x14(%ebp)
  8006fa:	eb 17                	jmp    800713 <vprintfmt+0x27e>
		return va_arg(*ap, long long);
  8006fc:	8b 45 14             	mov    0x14(%ebp),%eax
  8006ff:	8b 50 04             	mov    0x4(%eax),%edx
  800702:	8b 00                	mov    (%eax),%eax
  800704:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800707:	89 55 dc             	mov    %edx,-0x24(%ebp)
  80070a:	8b 45 14             	mov    0x14(%ebp),%eax
  80070d:	8d 40 08             	lea    0x8(%eax),%eax
  800710:	89 45 14             	mov    %eax,0x14(%ebp)
			if ((long long) num < 0) {
  800713:	8b 55 d8             	mov    -0x28(%ebp),%edx
  800716:	8b 4d dc             	mov    -0x24(%ebp),%ecx
			base = 10;
  800719:	b8 0a 00 00 00       	mov    $0xa,%eax
			if ((long long) num < 0) {
  80071e:	85 c9                	test   %ecx,%ecx
  800720:	0f 89 ca 00 00 00    	jns    8007f0 <vprintfmt+0x35b>
				putch('-', putdat);
  800726:	83 ec 08             	sub    $0x8,%esp
  800729:	53                   	push   %ebx
  80072a:	6a 2d                	push   $0x2d
  80072c:	ff d6                	call   *%esi
				num = -(long long) num;
  80072e:	8b 55 d8             	mov    -0x28(%ebp),%edx
  800731:	8b 4d dc             	mov    -0x24(%ebp),%ecx
  800734:	f7 da                	neg    %edx
  800736:	83 d1 00             	adc    $0x0,%ecx
  800739:	f7 d9                	neg    %ecx
  80073b:	83 c4 10             	add    $0x10,%esp
			base = 10;
  80073e:	b8 0a 00 00 00       	mov    $0xa,%eax
  800743:	e9 a8 00 00 00       	jmp    8007f0 <vprintfmt+0x35b>
		return va_arg(*ap, int);
  800748:	8b 45 14             	mov    0x14(%ebp),%eax
  80074b:	8b 00                	mov    (%eax),%eax
  80074d:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800750:	99                   	cltd   
  800751:	89 55 dc             	mov    %edx,-0x24(%ebp)
  800754:	8b 45 14             	mov    0x14(%ebp),%eax
  800757:	8d 40 04             	lea    0x4(%eax),%eax
  80075a:	89 45 14             	mov    %eax,0x14(%ebp)
  80075d:	eb b4                	jmp    800713 <vprintfmt+0x27e>
	if (lflag >= 2)
  80075f:	83 f9 01             	cmp    $0x1,%ecx
  800762:	7f 1b                	jg     80077f <vprintfmt+0x2ea>
	else if (lflag)
  800764:	85 c9                	test   %ecx,%ecx
  800766:	74 2c                	je     800794 <vprintfmt+0x2ff>
		return va_arg(*ap, unsigned long);
  800768:	8b 45 14             	mov    0x14(%ebp),%eax
  80076b:	8b 10                	mov    (%eax),%edx
  80076d:	b9 00 00 00 00       	mov    $0x0,%ecx
  800772:	8d 40 04             	lea    0x4(%eax),%eax
  800775:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 10;
  800778:	b8 0a 00 00 00       	mov    $0xa,%eax
		return va_arg(*ap, unsigned long);
  80077d:	eb 71                	jmp    8007f0 <vprintfmt+0x35b>
		return va_arg(*ap, unsigned long long);
  80077f:	8b 45 14             	mov    0x14(%ebp),%eax
  800782:	8b 10                	mov    (%eax),%edx
  800784:	8b 48 04             	mov    0x4(%eax),%ecx
  800787:	8d 40 08             	lea    0x8(%eax),%eax
  80078a:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 10;
  80078d:	b8 0a 00 00 00       	mov    $0xa,%eax
		return va_arg(*ap, unsigned long long);
  800792:	eb 5c                	jmp    8007f0 <vprintfmt+0x35b>
		return va_arg(*ap, unsigned int);
  800794:	8b 45 14             	mov    0x14(%ebp),%eax
  800797:	8b 10                	mov    (%eax),%edx
  800799:	b9 00 00 00 00       	mov    $0x0,%ecx
  80079e:	8d 40 04             	lea    0x4(%eax),%eax
  8007a1:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 10;
  8007a4:	b8 0a 00 00 00       	mov    $0xa,%eax
		return va_arg(*ap, unsigned int);
  8007a9:	eb 45                	jmp    8007f0 <vprintfmt+0x35b>
			putch('X', putdat);
  8007ab:	83 ec 08             	sub    $0x8,%esp
  8007ae:	53                   	push   %ebx
  8007af:	6a 58                	push   $0x58
  8007b1:	ff d6                	call   *%esi
			putch('X', putdat);
  8007b3:	83 c4 08             	add    $0x8,%esp
  8007b6:	53                   	push   %ebx
  8007b7:	6a 58                	push   $0x58
  8007b9:	ff d6                	call   *%esi
			putch('X', putdat);
  8007bb:	83 c4 08             	add    $0x8,%esp
  8007be:	53                   	push   %ebx
  8007bf:	6a 58                	push   $0x58
  8007c1:	ff d6                	call   *%esi
			break;
  8007c3:	83 c4 10             	add    $0x10,%esp
  8007c6:	eb 42                	jmp    80080a <vprintfmt+0x375>
			putch('0', putdat);
  8007c8:	83 ec 08             	sub    $0x8,%esp
  8007cb:	53                   	push   %ebx
  8007cc:	6a 30                	push   $0x30
  8007ce:	ff d6                	call   *%esi
			putch('x', putdat);
  8007d0:	83 c4 08             	add    $0x8,%esp
  8007d3:	53                   	push   %ebx
  8007d4:	6a 78                	push   $0x78
  8007d6:	ff d6                	call   *%esi
			num = (unsigned long long)
  8007d8:	8b 45 14             	mov    0x14(%ebp),%eax
  8007db:	8b 10                	mov    (%eax),%edx
  8007dd:	b9 00 00 00 00       	mov    $0x0,%ecx
			goto number;
  8007e2:	83 c4 10             	add    $0x10,%esp
				(uintptr_t) va_arg(ap, void *);
  8007e5:	8d 40 04             	lea    0x4(%eax),%eax
  8007e8:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 16;
  8007eb:	b8 10 00 00 00       	mov    $0x10,%eax
			printnum(putch, putdat, num, base, width, padc);
  8007f0:	83 ec 0c             	sub    $0xc,%esp
  8007f3:	0f be 7d d3          	movsbl -0x2d(%ebp),%edi
  8007f7:	57                   	push   %edi
  8007f8:	ff 75 d4             	pushl  -0x2c(%ebp)
  8007fb:	50                   	push   %eax
  8007fc:	51                   	push   %ecx
  8007fd:	52                   	push   %edx
  8007fe:	89 da                	mov    %ebx,%edx
  800800:	89 f0                	mov    %esi,%eax
  800802:	e8 a3 fb ff ff       	call   8003aa <printnum>
			break;
  800807:	83 c4 20             	add    $0x20,%esp
			if ((p = va_arg(ap, char *)) == NULL)
  80080a:	8b 7d e4             	mov    -0x1c(%ebp),%edi
		while ((ch = *(unsigned char *) fmt++) != '%') {
  80080d:	83 c7 01             	add    $0x1,%edi
  800810:	0f b6 47 ff          	movzbl -0x1(%edi),%eax
  800814:	83 f8 25             	cmp    $0x25,%eax
  800817:	0f 84 93 fc ff ff    	je     8004b0 <vprintfmt+0x1b>
			if (ch == '\0')
  80081d:	85 c0                	test   %eax,%eax
  80081f:	0f 84 8b 00 00 00    	je     8008b0 <vprintfmt+0x41b>
			putch(ch, putdat);
  800825:	83 ec 08             	sub    $0x8,%esp
  800828:	53                   	push   %ebx
  800829:	50                   	push   %eax
  80082a:	ff d6                	call   *%esi
  80082c:	83 c4 10             	add    $0x10,%esp
  80082f:	eb dc                	jmp    80080d <vprintfmt+0x378>
	if (lflag >= 2)
  800831:	83 f9 01             	cmp    $0x1,%ecx
  800834:	7f 1b                	jg     800851 <vprintfmt+0x3bc>
	else if (lflag)
  800836:	85 c9                	test   %ecx,%ecx
  800838:	74 2c                	je     800866 <vprintfmt+0x3d1>
		return va_arg(*ap, unsigned long);
  80083a:	8b 45 14             	mov    0x14(%ebp),%eax
  80083d:	8b 10                	mov    (%eax),%edx
  80083f:	b9 00 00 00 00       	mov    $0x0,%ecx
  800844:	8d 40 04             	lea    0x4(%eax),%eax
  800847:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 16;
  80084a:	b8 10 00 00 00       	mov    $0x10,%eax
		return va_arg(*ap, unsigned long);
  80084f:	eb 9f                	jmp    8007f0 <vprintfmt+0x35b>
		return va_arg(*ap, unsigned long long);
  800851:	8b 45 14             	mov    0x14(%ebp),%eax
  800854:	8b 10                	mov    (%eax),%edx
  800856:	8b 48 04             	mov    0x4(%eax),%ecx
  800859:	8d 40 08             	lea    0x8(%eax),%eax
  80085c:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 16;
  80085f:	b8 10 00 00 00       	mov    $0x10,%eax
		return va_arg(*ap, unsigned long long);
  800864:	eb 8a                	jmp    8007f0 <vprintfmt+0x35b>
		return va_arg(*ap, unsigned int);
  800866:	8b 45 14             	mov    0x14(%ebp),%eax
  800869:	8b 10                	mov    (%eax),%edx
  80086b:	b9 00 00 00 00       	mov    $0x0,%ecx
  800870:	8d 40 04             	lea    0x4(%eax),%eax
  800873:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 16;
  800876:	b8 10 00 00 00       	mov    $0x10,%eax
		return va_arg(*ap, unsigned int);
  80087b:	e9 70 ff ff ff       	jmp    8007f0 <vprintfmt+0x35b>
			putch(ch, putdat);
  800880:	83 ec 08             	sub    $0x8,%esp
  800883:	53                   	push   %ebx
  800884:	6a 25                	push   $0x25
  800886:	ff d6                	call   *%esi
			break;
  800888:	83 c4 10             	add    $0x10,%esp
  80088b:	e9 7a ff ff ff       	jmp    80080a <vprintfmt+0x375>
			putch('%', putdat);
  800890:	83 ec 08             	sub    $0x8,%esp
  800893:	53                   	push   %ebx
  800894:	6a 25                	push   $0x25
  800896:	ff d6                	call   *%esi
			for (fmt--; fmt[-1] != '%'; fmt--)
  800898:	83 c4 10             	add    $0x10,%esp
  80089b:	89 f8                	mov    %edi,%eax
  80089d:	80 78 ff 25          	cmpb   $0x25,-0x1(%eax)
  8008a1:	74 05                	je     8008a8 <vprintfmt+0x413>
  8008a3:	83 e8 01             	sub    $0x1,%eax
  8008a6:	eb f5                	jmp    80089d <vprintfmt+0x408>
  8008a8:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  8008ab:	e9 5a ff ff ff       	jmp    80080a <vprintfmt+0x375>
}
  8008b0:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8008b3:	5b                   	pop    %ebx
  8008b4:	5e                   	pop    %esi
  8008b5:	5f                   	pop    %edi
  8008b6:	5d                   	pop    %ebp
  8008b7:	c3                   	ret    

008008b8 <vsnprintf>:

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
  8008b8:	f3 0f 1e fb          	endbr32 
  8008bc:	55                   	push   %ebp
  8008bd:	89 e5                	mov    %esp,%ebp
  8008bf:	83 ec 18             	sub    $0x18,%esp
  8008c2:	8b 45 08             	mov    0x8(%ebp),%eax
  8008c5:	8b 55 0c             	mov    0xc(%ebp),%edx
	struct sprintbuf b = {buf, buf+n-1, 0};
  8008c8:	89 45 ec             	mov    %eax,-0x14(%ebp)
  8008cb:	8d 4c 10 ff          	lea    -0x1(%eax,%edx,1),%ecx
  8008cf:	89 4d f0             	mov    %ecx,-0x10(%ebp)
  8008d2:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)

	if (buf == NULL || n < 1)
  8008d9:	85 c0                	test   %eax,%eax
  8008db:	74 26                	je     800903 <vsnprintf+0x4b>
  8008dd:	85 d2                	test   %edx,%edx
  8008df:	7e 22                	jle    800903 <vsnprintf+0x4b>
		return -E_INVAL;

	// print the string to the buffer
	vprintfmt((void*)sprintputch, &b, fmt, ap);
  8008e1:	ff 75 14             	pushl  0x14(%ebp)
  8008e4:	ff 75 10             	pushl  0x10(%ebp)
  8008e7:	8d 45 ec             	lea    -0x14(%ebp),%eax
  8008ea:	50                   	push   %eax
  8008eb:	68 53 04 80 00       	push   $0x800453
  8008f0:	e8 a0 fb ff ff       	call   800495 <vprintfmt>

	// null terminate the buffer
	*b.buf = '\0';
  8008f5:	8b 45 ec             	mov    -0x14(%ebp),%eax
  8008f8:	c6 00 00             	movb   $0x0,(%eax)

	return b.cnt;
  8008fb:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8008fe:	83 c4 10             	add    $0x10,%esp
}
  800901:	c9                   	leave  
  800902:	c3                   	ret    
		return -E_INVAL;
  800903:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  800908:	eb f7                	jmp    800901 <vsnprintf+0x49>

0080090a <snprintf>:

int
snprintf(char *buf, int n, const char *fmt, ...)
{
  80090a:	f3 0f 1e fb          	endbr32 
  80090e:	55                   	push   %ebp
  80090f:	89 e5                	mov    %esp,%ebp
  800911:	83 ec 08             	sub    $0x8,%esp
	va_list ap;
	int rc;

	va_start(ap, fmt);
  800914:	8d 45 14             	lea    0x14(%ebp),%eax
	rc = vsnprintf(buf, n, fmt, ap);
  800917:	50                   	push   %eax
  800918:	ff 75 10             	pushl  0x10(%ebp)
  80091b:	ff 75 0c             	pushl  0xc(%ebp)
  80091e:	ff 75 08             	pushl  0x8(%ebp)
  800921:	e8 92 ff ff ff       	call   8008b8 <vsnprintf>
	va_end(ap);

	return rc;
}
  800926:	c9                   	leave  
  800927:	c3                   	ret    

00800928 <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1

int
strlen(const char *s)
{
  800928:	f3 0f 1e fb          	endbr32 
  80092c:	55                   	push   %ebp
  80092d:	89 e5                	mov    %esp,%ebp
  80092f:	8b 55 08             	mov    0x8(%ebp),%edx
	int n;

	for (n = 0; *s != '\0'; s++)
  800932:	b8 00 00 00 00       	mov    $0x0,%eax
  800937:	80 3c 02 00          	cmpb   $0x0,(%edx,%eax,1)
  80093b:	74 05                	je     800942 <strlen+0x1a>
		n++;
  80093d:	83 c0 01             	add    $0x1,%eax
  800940:	eb f5                	jmp    800937 <strlen+0xf>
	return n;
}
  800942:	5d                   	pop    %ebp
  800943:	c3                   	ret    

00800944 <strnlen>:

int
strnlen(const char *s, size_t size)
{
  800944:	f3 0f 1e fb          	endbr32 
  800948:	55                   	push   %ebp
  800949:	89 e5                	mov    %esp,%ebp
  80094b:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80094e:	8b 55 0c             	mov    0xc(%ebp),%edx
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800951:	b8 00 00 00 00       	mov    $0x0,%eax
  800956:	39 d0                	cmp    %edx,%eax
  800958:	74 0d                	je     800967 <strnlen+0x23>
  80095a:	80 3c 01 00          	cmpb   $0x0,(%ecx,%eax,1)
  80095e:	74 05                	je     800965 <strnlen+0x21>
		n++;
  800960:	83 c0 01             	add    $0x1,%eax
  800963:	eb f1                	jmp    800956 <strnlen+0x12>
  800965:	89 c2                	mov    %eax,%edx
	return n;
}
  800967:	89 d0                	mov    %edx,%eax
  800969:	5d                   	pop    %ebp
  80096a:	c3                   	ret    

0080096b <strcpy>:

char *
strcpy(char *dst, const char *src)
{
  80096b:	f3 0f 1e fb          	endbr32 
  80096f:	55                   	push   %ebp
  800970:	89 e5                	mov    %esp,%ebp
  800972:	53                   	push   %ebx
  800973:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800976:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	char *ret;

	ret = dst;
	while ((*dst++ = *src++) != '\0')
  800979:	b8 00 00 00 00       	mov    $0x0,%eax
  80097e:	0f b6 14 03          	movzbl (%ebx,%eax,1),%edx
  800982:	88 14 01             	mov    %dl,(%ecx,%eax,1)
  800985:	83 c0 01             	add    $0x1,%eax
  800988:	84 d2                	test   %dl,%dl
  80098a:	75 f2                	jne    80097e <strcpy+0x13>
		/* do nothing */;
	return ret;
}
  80098c:	89 c8                	mov    %ecx,%eax
  80098e:	5b                   	pop    %ebx
  80098f:	5d                   	pop    %ebp
  800990:	c3                   	ret    

00800991 <strcat>:

char *
strcat(char *dst, const char *src)
{
  800991:	f3 0f 1e fb          	endbr32 
  800995:	55                   	push   %ebp
  800996:	89 e5                	mov    %esp,%ebp
  800998:	53                   	push   %ebx
  800999:	83 ec 10             	sub    $0x10,%esp
  80099c:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int len = strlen(dst);
  80099f:	53                   	push   %ebx
  8009a0:	e8 83 ff ff ff       	call   800928 <strlen>
  8009a5:	83 c4 08             	add    $0x8,%esp
	strcpy(dst + len, src);
  8009a8:	ff 75 0c             	pushl  0xc(%ebp)
  8009ab:	01 d8                	add    %ebx,%eax
  8009ad:	50                   	push   %eax
  8009ae:	e8 b8 ff ff ff       	call   80096b <strcpy>
	return dst;
}
  8009b3:	89 d8                	mov    %ebx,%eax
  8009b5:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  8009b8:	c9                   	leave  
  8009b9:	c3                   	ret    

008009ba <strncpy>:

char *
strncpy(char *dst, const char *src, size_t size) {
  8009ba:	f3 0f 1e fb          	endbr32 
  8009be:	55                   	push   %ebp
  8009bf:	89 e5                	mov    %esp,%ebp
  8009c1:	56                   	push   %esi
  8009c2:	53                   	push   %ebx
  8009c3:	8b 75 08             	mov    0x8(%ebp),%esi
  8009c6:	8b 55 0c             	mov    0xc(%ebp),%edx
  8009c9:	89 f3                	mov    %esi,%ebx
  8009cb:	03 5d 10             	add    0x10(%ebp),%ebx
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  8009ce:	89 f0                	mov    %esi,%eax
  8009d0:	39 d8                	cmp    %ebx,%eax
  8009d2:	74 11                	je     8009e5 <strncpy+0x2b>
		*dst++ = *src;
  8009d4:	83 c0 01             	add    $0x1,%eax
  8009d7:	0f b6 0a             	movzbl (%edx),%ecx
  8009da:	88 48 ff             	mov    %cl,-0x1(%eax)
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
  8009dd:	80 f9 01             	cmp    $0x1,%cl
  8009e0:	83 da ff             	sbb    $0xffffffff,%edx
  8009e3:	eb eb                	jmp    8009d0 <strncpy+0x16>
	}
	return ret;
}
  8009e5:	89 f0                	mov    %esi,%eax
  8009e7:	5b                   	pop    %ebx
  8009e8:	5e                   	pop    %esi
  8009e9:	5d                   	pop    %ebp
  8009ea:	c3                   	ret    

008009eb <strlcpy>:

size_t
strlcpy(char *dst, const char *src, size_t size)
{
  8009eb:	f3 0f 1e fb          	endbr32 
  8009ef:	55                   	push   %ebp
  8009f0:	89 e5                	mov    %esp,%ebp
  8009f2:	56                   	push   %esi
  8009f3:	53                   	push   %ebx
  8009f4:	8b 75 08             	mov    0x8(%ebp),%esi
  8009f7:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8009fa:	8b 55 10             	mov    0x10(%ebp),%edx
  8009fd:	89 f0                	mov    %esi,%eax
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
  8009ff:	85 d2                	test   %edx,%edx
  800a01:	74 21                	je     800a24 <strlcpy+0x39>
  800a03:	8d 44 16 ff          	lea    -0x1(%esi,%edx,1),%eax
  800a07:	89 f2                	mov    %esi,%edx
		while (--size > 0 && *src != '\0')
  800a09:	39 c2                	cmp    %eax,%edx
  800a0b:	74 14                	je     800a21 <strlcpy+0x36>
  800a0d:	0f b6 19             	movzbl (%ecx),%ebx
  800a10:	84 db                	test   %bl,%bl
  800a12:	74 0b                	je     800a1f <strlcpy+0x34>
			*dst++ = *src++;
  800a14:	83 c1 01             	add    $0x1,%ecx
  800a17:	83 c2 01             	add    $0x1,%edx
  800a1a:	88 5a ff             	mov    %bl,-0x1(%edx)
  800a1d:	eb ea                	jmp    800a09 <strlcpy+0x1e>
  800a1f:	89 d0                	mov    %edx,%eax
		*dst = '\0';
  800a21:	c6 00 00             	movb   $0x0,(%eax)
	}
	return dst - dst_in;
  800a24:	29 f0                	sub    %esi,%eax
}
  800a26:	5b                   	pop    %ebx
  800a27:	5e                   	pop    %esi
  800a28:	5d                   	pop    %ebp
  800a29:	c3                   	ret    

00800a2a <strcmp>:

int
strcmp(const char *p, const char *q)
{
  800a2a:	f3 0f 1e fb          	endbr32 
  800a2e:	55                   	push   %ebp
  800a2f:	89 e5                	mov    %esp,%ebp
  800a31:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800a34:	8b 55 0c             	mov    0xc(%ebp),%edx
	while (*p && *p == *q)
  800a37:	0f b6 01             	movzbl (%ecx),%eax
  800a3a:	84 c0                	test   %al,%al
  800a3c:	74 0c                	je     800a4a <strcmp+0x20>
  800a3e:	3a 02                	cmp    (%edx),%al
  800a40:	75 08                	jne    800a4a <strcmp+0x20>
		p++, q++;
  800a42:	83 c1 01             	add    $0x1,%ecx
  800a45:	83 c2 01             	add    $0x1,%edx
  800a48:	eb ed                	jmp    800a37 <strcmp+0xd>
	return (int) ((unsigned char) *p - (unsigned char) *q);
  800a4a:	0f b6 c0             	movzbl %al,%eax
  800a4d:	0f b6 12             	movzbl (%edx),%edx
  800a50:	29 d0                	sub    %edx,%eax
}
  800a52:	5d                   	pop    %ebp
  800a53:	c3                   	ret    

00800a54 <strncmp>:

int
strncmp(const char *p, const char *q, size_t n)
{
  800a54:	f3 0f 1e fb          	endbr32 
  800a58:	55                   	push   %ebp
  800a59:	89 e5                	mov    %esp,%ebp
  800a5b:	53                   	push   %ebx
  800a5c:	8b 45 08             	mov    0x8(%ebp),%eax
  800a5f:	8b 55 0c             	mov    0xc(%ebp),%edx
  800a62:	89 c3                	mov    %eax,%ebx
  800a64:	03 5d 10             	add    0x10(%ebp),%ebx
	while (n > 0 && *p && *p == *q)
  800a67:	eb 06                	jmp    800a6f <strncmp+0x1b>
		n--, p++, q++;
  800a69:	83 c0 01             	add    $0x1,%eax
  800a6c:	83 c2 01             	add    $0x1,%edx
	while (n > 0 && *p && *p == *q)
  800a6f:	39 d8                	cmp    %ebx,%eax
  800a71:	74 16                	je     800a89 <strncmp+0x35>
  800a73:	0f b6 08             	movzbl (%eax),%ecx
  800a76:	84 c9                	test   %cl,%cl
  800a78:	74 04                	je     800a7e <strncmp+0x2a>
  800a7a:	3a 0a                	cmp    (%edx),%cl
  800a7c:	74 eb                	je     800a69 <strncmp+0x15>
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
  800a7e:	0f b6 00             	movzbl (%eax),%eax
  800a81:	0f b6 12             	movzbl (%edx),%edx
  800a84:	29 d0                	sub    %edx,%eax
}
  800a86:	5b                   	pop    %ebx
  800a87:	5d                   	pop    %ebp
  800a88:	c3                   	ret    
		return 0;
  800a89:	b8 00 00 00 00       	mov    $0x0,%eax
  800a8e:	eb f6                	jmp    800a86 <strncmp+0x32>

00800a90 <strchr>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
  800a90:	f3 0f 1e fb          	endbr32 
  800a94:	55                   	push   %ebp
  800a95:	89 e5                	mov    %esp,%ebp
  800a97:	8b 45 08             	mov    0x8(%ebp),%eax
  800a9a:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800a9e:	0f b6 10             	movzbl (%eax),%edx
  800aa1:	84 d2                	test   %dl,%dl
  800aa3:	74 09                	je     800aae <strchr+0x1e>
		if (*s == c)
  800aa5:	38 ca                	cmp    %cl,%dl
  800aa7:	74 0a                	je     800ab3 <strchr+0x23>
	for (; *s; s++)
  800aa9:	83 c0 01             	add    $0x1,%eax
  800aac:	eb f0                	jmp    800a9e <strchr+0xe>
			return (char *) s;
	return 0;
  800aae:	b8 00 00 00 00       	mov    $0x0,%eax
}
  800ab3:	5d                   	pop    %ebp
  800ab4:	c3                   	ret    

00800ab5 <strfind>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
  800ab5:	f3 0f 1e fb          	endbr32 
  800ab9:	55                   	push   %ebp
  800aba:	89 e5                	mov    %esp,%ebp
  800abc:	8b 45 08             	mov    0x8(%ebp),%eax
  800abf:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800ac3:	0f b6 10             	movzbl (%eax),%edx
		if (*s == c)
  800ac6:	38 ca                	cmp    %cl,%dl
  800ac8:	74 09                	je     800ad3 <strfind+0x1e>
  800aca:	84 d2                	test   %dl,%dl
  800acc:	74 05                	je     800ad3 <strfind+0x1e>
	for (; *s; s++)
  800ace:	83 c0 01             	add    $0x1,%eax
  800ad1:	eb f0                	jmp    800ac3 <strfind+0xe>
			break;
	return (char *) s;
}
  800ad3:	5d                   	pop    %ebp
  800ad4:	c3                   	ret    

00800ad5 <memset>:

#if ASM
void *
memset(void *v, int c, size_t n)
{
  800ad5:	f3 0f 1e fb          	endbr32 
  800ad9:	55                   	push   %ebp
  800ada:	89 e5                	mov    %esp,%ebp
  800adc:	57                   	push   %edi
  800add:	56                   	push   %esi
  800ade:	53                   	push   %ebx
  800adf:	8b 7d 08             	mov    0x8(%ebp),%edi
  800ae2:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *p;

	if (n == 0)
  800ae5:	85 c9                	test   %ecx,%ecx
  800ae7:	74 31                	je     800b1a <memset+0x45>
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800ae9:	89 f8                	mov    %edi,%eax
  800aeb:	09 c8                	or     %ecx,%eax
  800aed:	a8 03                	test   $0x3,%al
  800aef:	75 23                	jne    800b14 <memset+0x3f>
		c &= 0xFF;
  800af1:	0f b6 55 0c          	movzbl 0xc(%ebp),%edx
		c = (c<<24)|(c<<16)|(c<<8)|c;
  800af5:	89 d3                	mov    %edx,%ebx
  800af7:	c1 e3 08             	shl    $0x8,%ebx
  800afa:	89 d0                	mov    %edx,%eax
  800afc:	c1 e0 18             	shl    $0x18,%eax
  800aff:	89 d6                	mov    %edx,%esi
  800b01:	c1 e6 10             	shl    $0x10,%esi
  800b04:	09 f0                	or     %esi,%eax
  800b06:	09 c2                	or     %eax,%edx
  800b08:	09 da                	or     %ebx,%edx
		asm volatile("cld; rep stosl\n"
			:: "D" (v), "a" (c), "c" (n/4)
  800b0a:	c1 e9 02             	shr    $0x2,%ecx
		asm volatile("cld; rep stosl\n"
  800b0d:	89 d0                	mov    %edx,%eax
  800b0f:	fc                   	cld    
  800b10:	f3 ab                	rep stos %eax,%es:(%edi)
  800b12:	eb 06                	jmp    800b1a <memset+0x45>
			: "cc", "memory");
	} else
		asm volatile("cld; rep stosb\n"
  800b14:	8b 45 0c             	mov    0xc(%ebp),%eax
  800b17:	fc                   	cld    
  800b18:	f3 aa                	rep stos %al,%es:(%edi)
			:: "D" (v), "a" (c), "c" (n)
			: "cc", "memory");
	return v;
}
  800b1a:	89 f8                	mov    %edi,%eax
  800b1c:	5b                   	pop    %ebx
  800b1d:	5e                   	pop    %esi
  800b1e:	5f                   	pop    %edi
  800b1f:	5d                   	pop    %ebp
  800b20:	c3                   	ret    

00800b21 <memmove>:

void *
memmove(void *dst, const void *src, size_t n)
{
  800b21:	f3 0f 1e fb          	endbr32 
  800b25:	55                   	push   %ebp
  800b26:	89 e5                	mov    %esp,%ebp
  800b28:	57                   	push   %edi
  800b29:	56                   	push   %esi
  800b2a:	8b 45 08             	mov    0x8(%ebp),%eax
  800b2d:	8b 75 0c             	mov    0xc(%ebp),%esi
  800b30:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const char *s;
	char *d;

	s = src;
	d = dst;
	if (s < d && s + n > d) {
  800b33:	39 c6                	cmp    %eax,%esi
  800b35:	73 32                	jae    800b69 <memmove+0x48>
  800b37:	8d 14 0e             	lea    (%esi,%ecx,1),%edx
  800b3a:	39 c2                	cmp    %eax,%edx
  800b3c:	76 2b                	jbe    800b69 <memmove+0x48>
		s += n;
		d += n;
  800b3e:	8d 3c 08             	lea    (%eax,%ecx,1),%edi
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800b41:	89 fe                	mov    %edi,%esi
  800b43:	09 ce                	or     %ecx,%esi
  800b45:	09 d6                	or     %edx,%esi
  800b47:	f7 c6 03 00 00 00    	test   $0x3,%esi
  800b4d:	75 0e                	jne    800b5d <memmove+0x3c>
			asm volatile("std; rep movsl\n"
				:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
  800b4f:	83 ef 04             	sub    $0x4,%edi
  800b52:	8d 72 fc             	lea    -0x4(%edx),%esi
  800b55:	c1 e9 02             	shr    $0x2,%ecx
			asm volatile("std; rep movsl\n"
  800b58:	fd                   	std    
  800b59:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
  800b5b:	eb 09                	jmp    800b66 <memmove+0x45>
		else
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
  800b5d:	83 ef 01             	sub    $0x1,%edi
  800b60:	8d 72 ff             	lea    -0x1(%edx),%esi
			asm volatile("std; rep movsb\n"
  800b63:	fd                   	std    
  800b64:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
  800b66:	fc                   	cld    
  800b67:	eb 1a                	jmp    800b83 <memmove+0x62>
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800b69:	89 c2                	mov    %eax,%edx
  800b6b:	09 ca                	or     %ecx,%edx
  800b6d:	09 f2                	or     %esi,%edx
  800b6f:	f6 c2 03             	test   $0x3,%dl
  800b72:	75 0a                	jne    800b7e <memmove+0x5d>
			asm volatile("cld; rep movsl\n"
				:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
  800b74:	c1 e9 02             	shr    $0x2,%ecx
			asm volatile("cld; rep movsl\n"
  800b77:	89 c7                	mov    %eax,%edi
  800b79:	fc                   	cld    
  800b7a:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
  800b7c:	eb 05                	jmp    800b83 <memmove+0x62>
		else
			asm volatile("cld; rep movsb\n"
  800b7e:	89 c7                	mov    %eax,%edi
  800b80:	fc                   	cld    
  800b81:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
	}
	return dst;
}
  800b83:	5e                   	pop    %esi
  800b84:	5f                   	pop    %edi
  800b85:	5d                   	pop    %ebp
  800b86:	c3                   	ret    

00800b87 <memcpy>:
}
#endif

void *
memcpy(void *dst, const void *src, size_t n)
{
  800b87:	f3 0f 1e fb          	endbr32 
  800b8b:	55                   	push   %ebp
  800b8c:	89 e5                	mov    %esp,%ebp
  800b8e:	83 ec 0c             	sub    $0xc,%esp
	return memmove(dst, src, n);
  800b91:	ff 75 10             	pushl  0x10(%ebp)
  800b94:	ff 75 0c             	pushl  0xc(%ebp)
  800b97:	ff 75 08             	pushl  0x8(%ebp)
  800b9a:	e8 82 ff ff ff       	call   800b21 <memmove>
}
  800b9f:	c9                   	leave  
  800ba0:	c3                   	ret    

00800ba1 <memcmp>:

int
memcmp(const void *v1, const void *v2, size_t n)
{
  800ba1:	f3 0f 1e fb          	endbr32 
  800ba5:	55                   	push   %ebp
  800ba6:	89 e5                	mov    %esp,%ebp
  800ba8:	56                   	push   %esi
  800ba9:	53                   	push   %ebx
  800baa:	8b 45 08             	mov    0x8(%ebp),%eax
  800bad:	8b 55 0c             	mov    0xc(%ebp),%edx
  800bb0:	89 c6                	mov    %eax,%esi
  800bb2:	03 75 10             	add    0x10(%ebp),%esi
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800bb5:	39 f0                	cmp    %esi,%eax
  800bb7:	74 1c                	je     800bd5 <memcmp+0x34>
		if (*s1 != *s2)
  800bb9:	0f b6 08             	movzbl (%eax),%ecx
  800bbc:	0f b6 1a             	movzbl (%edx),%ebx
  800bbf:	38 d9                	cmp    %bl,%cl
  800bc1:	75 08                	jne    800bcb <memcmp+0x2a>
			return (int) *s1 - (int) *s2;
		s1++, s2++;
  800bc3:	83 c0 01             	add    $0x1,%eax
  800bc6:	83 c2 01             	add    $0x1,%edx
  800bc9:	eb ea                	jmp    800bb5 <memcmp+0x14>
			return (int) *s1 - (int) *s2;
  800bcb:	0f b6 c1             	movzbl %cl,%eax
  800bce:	0f b6 db             	movzbl %bl,%ebx
  800bd1:	29 d8                	sub    %ebx,%eax
  800bd3:	eb 05                	jmp    800bda <memcmp+0x39>
	}

	return 0;
  800bd5:	b8 00 00 00 00       	mov    $0x0,%eax
}
  800bda:	5b                   	pop    %ebx
  800bdb:	5e                   	pop    %esi
  800bdc:	5d                   	pop    %ebp
  800bdd:	c3                   	ret    

00800bde <memfind>:

void *
memfind(const void *s, int c, size_t n)
{
  800bde:	f3 0f 1e fb          	endbr32 
  800be2:	55                   	push   %ebp
  800be3:	89 e5                	mov    %esp,%ebp
  800be5:	8b 45 08             	mov    0x8(%ebp),%eax
  800be8:	8b 4d 0c             	mov    0xc(%ebp),%ecx
	const void *ends = (const char *) s + n;
  800beb:	89 c2                	mov    %eax,%edx
  800bed:	03 55 10             	add    0x10(%ebp),%edx
	for (; s < ends; s++)
  800bf0:	39 d0                	cmp    %edx,%eax
  800bf2:	73 09                	jae    800bfd <memfind+0x1f>
		if (*(const unsigned char *) s == (unsigned char) c)
  800bf4:	38 08                	cmp    %cl,(%eax)
  800bf6:	74 05                	je     800bfd <memfind+0x1f>
	for (; s < ends; s++)
  800bf8:	83 c0 01             	add    $0x1,%eax
  800bfb:	eb f3                	jmp    800bf0 <memfind+0x12>
			break;
	return (void *) s;
}
  800bfd:	5d                   	pop    %ebp
  800bfe:	c3                   	ret    

00800bff <strtol>:

long
strtol(const char *s, char **endptr, int base)
{
  800bff:	f3 0f 1e fb          	endbr32 
  800c03:	55                   	push   %ebp
  800c04:	89 e5                	mov    %esp,%ebp
  800c06:	57                   	push   %edi
  800c07:	56                   	push   %esi
  800c08:	53                   	push   %ebx
  800c09:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800c0c:	8b 5d 10             	mov    0x10(%ebp),%ebx
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800c0f:	eb 03                	jmp    800c14 <strtol+0x15>
		s++;
  800c11:	83 c1 01             	add    $0x1,%ecx
	while (*s == ' ' || *s == '\t')
  800c14:	0f b6 01             	movzbl (%ecx),%eax
  800c17:	3c 20                	cmp    $0x20,%al
  800c19:	74 f6                	je     800c11 <strtol+0x12>
  800c1b:	3c 09                	cmp    $0x9,%al
  800c1d:	74 f2                	je     800c11 <strtol+0x12>

	// plus/minus sign
	if (*s == '+')
  800c1f:	3c 2b                	cmp    $0x2b,%al
  800c21:	74 2a                	je     800c4d <strtol+0x4e>
	int neg = 0;
  800c23:	bf 00 00 00 00       	mov    $0x0,%edi
		s++;
	else if (*s == '-')
  800c28:	3c 2d                	cmp    $0x2d,%al
  800c2a:	74 2b                	je     800c57 <strtol+0x58>
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800c2c:	f7 c3 ef ff ff ff    	test   $0xffffffef,%ebx
  800c32:	75 0f                	jne    800c43 <strtol+0x44>
  800c34:	80 39 30             	cmpb   $0x30,(%ecx)
  800c37:	74 28                	je     800c61 <strtol+0x62>
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
		s++, base = 8;
	else if (base == 0)
		base = 10;
  800c39:	85 db                	test   %ebx,%ebx
  800c3b:	b8 0a 00 00 00       	mov    $0xa,%eax
  800c40:	0f 44 d8             	cmove  %eax,%ebx
  800c43:	b8 00 00 00 00       	mov    $0x0,%eax
  800c48:	89 5d 10             	mov    %ebx,0x10(%ebp)
  800c4b:	eb 46                	jmp    800c93 <strtol+0x94>
		s++;
  800c4d:	83 c1 01             	add    $0x1,%ecx
	int neg = 0;
  800c50:	bf 00 00 00 00       	mov    $0x0,%edi
  800c55:	eb d5                	jmp    800c2c <strtol+0x2d>
		s++, neg = 1;
  800c57:	83 c1 01             	add    $0x1,%ecx
  800c5a:	bf 01 00 00 00       	mov    $0x1,%edi
  800c5f:	eb cb                	jmp    800c2c <strtol+0x2d>
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800c61:	80 79 01 78          	cmpb   $0x78,0x1(%ecx)
  800c65:	74 0e                	je     800c75 <strtol+0x76>
	else if (base == 0 && s[0] == '0')
  800c67:	85 db                	test   %ebx,%ebx
  800c69:	75 d8                	jne    800c43 <strtol+0x44>
		s++, base = 8;
  800c6b:	83 c1 01             	add    $0x1,%ecx
  800c6e:	bb 08 00 00 00       	mov    $0x8,%ebx
  800c73:	eb ce                	jmp    800c43 <strtol+0x44>
		s += 2, base = 16;
  800c75:	83 c1 02             	add    $0x2,%ecx
  800c78:	bb 10 00 00 00       	mov    $0x10,%ebx
  800c7d:	eb c4                	jmp    800c43 <strtol+0x44>
	// digits
	while (1) {
		int dig;

		if (*s >= '0' && *s <= '9')
			dig = *s - '0';
  800c7f:	0f be d2             	movsbl %dl,%edx
  800c82:	83 ea 30             	sub    $0x30,%edx
			dig = *s - 'a' + 10;
		else if (*s >= 'A' && *s <= 'Z')
			dig = *s - 'A' + 10;
		else
			break;
		if (dig >= base)
  800c85:	3b 55 10             	cmp    0x10(%ebp),%edx
  800c88:	7d 3a                	jge    800cc4 <strtol+0xc5>
			break;
		s++, val = (val * base) + dig;
  800c8a:	83 c1 01             	add    $0x1,%ecx
  800c8d:	0f af 45 10          	imul   0x10(%ebp),%eax
  800c91:	01 d0                	add    %edx,%eax
		if (*s >= '0' && *s <= '9')
  800c93:	0f b6 11             	movzbl (%ecx),%edx
  800c96:	8d 72 d0             	lea    -0x30(%edx),%esi
  800c99:	89 f3                	mov    %esi,%ebx
  800c9b:	80 fb 09             	cmp    $0x9,%bl
  800c9e:	76 df                	jbe    800c7f <strtol+0x80>
		else if (*s >= 'a' && *s <= 'z')
  800ca0:	8d 72 9f             	lea    -0x61(%edx),%esi
  800ca3:	89 f3                	mov    %esi,%ebx
  800ca5:	80 fb 19             	cmp    $0x19,%bl
  800ca8:	77 08                	ja     800cb2 <strtol+0xb3>
			dig = *s - 'a' + 10;
  800caa:	0f be d2             	movsbl %dl,%edx
  800cad:	83 ea 57             	sub    $0x57,%edx
  800cb0:	eb d3                	jmp    800c85 <strtol+0x86>
		else if (*s >= 'A' && *s <= 'Z')
  800cb2:	8d 72 bf             	lea    -0x41(%edx),%esi
  800cb5:	89 f3                	mov    %esi,%ebx
  800cb7:	80 fb 19             	cmp    $0x19,%bl
  800cba:	77 08                	ja     800cc4 <strtol+0xc5>
			dig = *s - 'A' + 10;
  800cbc:	0f be d2             	movsbl %dl,%edx
  800cbf:	83 ea 37             	sub    $0x37,%edx
  800cc2:	eb c1                	jmp    800c85 <strtol+0x86>
		// we don't properly detect overflow!
	}

	if (endptr)
  800cc4:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  800cc8:	74 05                	je     800ccf <strtol+0xd0>
		*endptr = (char *) s;
  800cca:	8b 75 0c             	mov    0xc(%ebp),%esi
  800ccd:	89 0e                	mov    %ecx,(%esi)
	return (neg ? -val : val);
  800ccf:	89 c2                	mov    %eax,%edx
  800cd1:	f7 da                	neg    %edx
  800cd3:	85 ff                	test   %edi,%edi
  800cd5:	0f 45 c2             	cmovne %edx,%eax
}
  800cd8:	5b                   	pop    %ebx
  800cd9:	5e                   	pop    %esi
  800cda:	5f                   	pop    %edi
  800cdb:	5d                   	pop    %ebp
  800cdc:	c3                   	ret    

00800cdd <sys_cputs>:
	return ret;
}

void
sys_cputs(const char *s, size_t len)
{
  800cdd:	f3 0f 1e fb          	endbr32 
  800ce1:	55                   	push   %ebp
  800ce2:	89 e5                	mov    %esp,%ebp
  800ce4:	57                   	push   %edi
  800ce5:	56                   	push   %esi
  800ce6:	53                   	push   %ebx
	asm volatile("int %1\n"
  800ce7:	b8 00 00 00 00       	mov    $0x0,%eax
  800cec:	8b 55 08             	mov    0x8(%ebp),%edx
  800cef:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800cf2:	89 c3                	mov    %eax,%ebx
  800cf4:	89 c7                	mov    %eax,%edi
  800cf6:	89 c6                	mov    %eax,%esi
  800cf8:	cd 30                	int    $0x30
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
  800cfa:	5b                   	pop    %ebx
  800cfb:	5e                   	pop    %esi
  800cfc:	5f                   	pop    %edi
  800cfd:	5d                   	pop    %ebp
  800cfe:	c3                   	ret    

00800cff <sys_cgetc>:

int
sys_cgetc(void)
{
  800cff:	f3 0f 1e fb          	endbr32 
  800d03:	55                   	push   %ebp
  800d04:	89 e5                	mov    %esp,%ebp
  800d06:	57                   	push   %edi
  800d07:	56                   	push   %esi
  800d08:	53                   	push   %ebx
	asm volatile("int %1\n"
  800d09:	ba 00 00 00 00       	mov    $0x0,%edx
  800d0e:	b8 01 00 00 00       	mov    $0x1,%eax
  800d13:	89 d1                	mov    %edx,%ecx
  800d15:	89 d3                	mov    %edx,%ebx
  800d17:	89 d7                	mov    %edx,%edi
  800d19:	89 d6                	mov    %edx,%esi
  800d1b:	cd 30                	int    $0x30
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
  800d1d:	5b                   	pop    %ebx
  800d1e:	5e                   	pop    %esi
  800d1f:	5f                   	pop    %edi
  800d20:	5d                   	pop    %ebp
  800d21:	c3                   	ret    

00800d22 <sys_env_destroy>:

int
sys_env_destroy(envid_t envid)
{
  800d22:	f3 0f 1e fb          	endbr32 
  800d26:	55                   	push   %ebp
  800d27:	89 e5                	mov    %esp,%ebp
  800d29:	57                   	push   %edi
  800d2a:	56                   	push   %esi
  800d2b:	53                   	push   %ebx
  800d2c:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  800d2f:	b9 00 00 00 00       	mov    $0x0,%ecx
  800d34:	8b 55 08             	mov    0x8(%ebp),%edx
  800d37:	b8 03 00 00 00       	mov    $0x3,%eax
  800d3c:	89 cb                	mov    %ecx,%ebx
  800d3e:	89 cf                	mov    %ecx,%edi
  800d40:	89 ce                	mov    %ecx,%esi
  800d42:	cd 30                	int    $0x30
	if(check && ret > 0)
  800d44:	85 c0                	test   %eax,%eax
  800d46:	7f 08                	jg     800d50 <sys_env_destroy+0x2e>
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
  800d48:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800d4b:	5b                   	pop    %ebx
  800d4c:	5e                   	pop    %esi
  800d4d:	5f                   	pop    %edi
  800d4e:	5d                   	pop    %ebp
  800d4f:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  800d50:	83 ec 0c             	sub    $0xc,%esp
  800d53:	50                   	push   %eax
  800d54:	6a 03                	push   $0x3
  800d56:	68 7f 28 80 00       	push   $0x80287f
  800d5b:	6a 23                	push   $0x23
  800d5d:	68 9c 28 80 00       	push   $0x80289c
  800d62:	e8 44 f5 ff ff       	call   8002ab <_panic>

00800d67 <sys_getenvid>:

envid_t
sys_getenvid(void)
{
  800d67:	f3 0f 1e fb          	endbr32 
  800d6b:	55                   	push   %ebp
  800d6c:	89 e5                	mov    %esp,%ebp
  800d6e:	57                   	push   %edi
  800d6f:	56                   	push   %esi
  800d70:	53                   	push   %ebx
	asm volatile("int %1\n"
  800d71:	ba 00 00 00 00       	mov    $0x0,%edx
  800d76:	b8 02 00 00 00       	mov    $0x2,%eax
  800d7b:	89 d1                	mov    %edx,%ecx
  800d7d:	89 d3                	mov    %edx,%ebx
  800d7f:	89 d7                	mov    %edx,%edi
  800d81:	89 d6                	mov    %edx,%esi
  800d83:	cd 30                	int    $0x30
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
  800d85:	5b                   	pop    %ebx
  800d86:	5e                   	pop    %esi
  800d87:	5f                   	pop    %edi
  800d88:	5d                   	pop    %ebp
  800d89:	c3                   	ret    

00800d8a <sys_yield>:

void
sys_yield(void)
{
  800d8a:	f3 0f 1e fb          	endbr32 
  800d8e:	55                   	push   %ebp
  800d8f:	89 e5                	mov    %esp,%ebp
  800d91:	57                   	push   %edi
  800d92:	56                   	push   %esi
  800d93:	53                   	push   %ebx
	asm volatile("int %1\n"
  800d94:	ba 00 00 00 00       	mov    $0x0,%edx
  800d99:	b8 0b 00 00 00       	mov    $0xb,%eax
  800d9e:	89 d1                	mov    %edx,%ecx
  800da0:	89 d3                	mov    %edx,%ebx
  800da2:	89 d7                	mov    %edx,%edi
  800da4:	89 d6                	mov    %edx,%esi
  800da6:	cd 30                	int    $0x30
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
  800da8:	5b                   	pop    %ebx
  800da9:	5e                   	pop    %esi
  800daa:	5f                   	pop    %edi
  800dab:	5d                   	pop    %ebp
  800dac:	c3                   	ret    

00800dad <sys_page_alloc>:

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
  800dad:	f3 0f 1e fb          	endbr32 
  800db1:	55                   	push   %ebp
  800db2:	89 e5                	mov    %esp,%ebp
  800db4:	57                   	push   %edi
  800db5:	56                   	push   %esi
  800db6:	53                   	push   %ebx
  800db7:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  800dba:	be 00 00 00 00       	mov    $0x0,%esi
  800dbf:	8b 55 08             	mov    0x8(%ebp),%edx
  800dc2:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800dc5:	b8 04 00 00 00       	mov    $0x4,%eax
  800dca:	8b 5d 10             	mov    0x10(%ebp),%ebx
  800dcd:	89 f7                	mov    %esi,%edi
  800dcf:	cd 30                	int    $0x30
	if(check && ret > 0)
  800dd1:	85 c0                	test   %eax,%eax
  800dd3:	7f 08                	jg     800ddd <sys_page_alloc+0x30>
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
  800dd5:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800dd8:	5b                   	pop    %ebx
  800dd9:	5e                   	pop    %esi
  800dda:	5f                   	pop    %edi
  800ddb:	5d                   	pop    %ebp
  800ddc:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  800ddd:	83 ec 0c             	sub    $0xc,%esp
  800de0:	50                   	push   %eax
  800de1:	6a 04                	push   $0x4
  800de3:	68 7f 28 80 00       	push   $0x80287f
  800de8:	6a 23                	push   $0x23
  800dea:	68 9c 28 80 00       	push   $0x80289c
  800def:	e8 b7 f4 ff ff       	call   8002ab <_panic>

00800df4 <sys_page_map>:

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
  800df4:	f3 0f 1e fb          	endbr32 
  800df8:	55                   	push   %ebp
  800df9:	89 e5                	mov    %esp,%ebp
  800dfb:	57                   	push   %edi
  800dfc:	56                   	push   %esi
  800dfd:	53                   	push   %ebx
  800dfe:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  800e01:	8b 55 08             	mov    0x8(%ebp),%edx
  800e04:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800e07:	b8 05 00 00 00       	mov    $0x5,%eax
  800e0c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  800e0f:	8b 7d 14             	mov    0x14(%ebp),%edi
  800e12:	8b 75 18             	mov    0x18(%ebp),%esi
  800e15:	cd 30                	int    $0x30
	if(check && ret > 0)
  800e17:	85 c0                	test   %eax,%eax
  800e19:	7f 08                	jg     800e23 <sys_page_map+0x2f>
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
  800e1b:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800e1e:	5b                   	pop    %ebx
  800e1f:	5e                   	pop    %esi
  800e20:	5f                   	pop    %edi
  800e21:	5d                   	pop    %ebp
  800e22:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  800e23:	83 ec 0c             	sub    $0xc,%esp
  800e26:	50                   	push   %eax
  800e27:	6a 05                	push   $0x5
  800e29:	68 7f 28 80 00       	push   $0x80287f
  800e2e:	6a 23                	push   $0x23
  800e30:	68 9c 28 80 00       	push   $0x80289c
  800e35:	e8 71 f4 ff ff       	call   8002ab <_panic>

00800e3a <sys_page_unmap>:

int
sys_page_unmap(envid_t envid, void *va)
{
  800e3a:	f3 0f 1e fb          	endbr32 
  800e3e:	55                   	push   %ebp
  800e3f:	89 e5                	mov    %esp,%ebp
  800e41:	57                   	push   %edi
  800e42:	56                   	push   %esi
  800e43:	53                   	push   %ebx
  800e44:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  800e47:	bb 00 00 00 00       	mov    $0x0,%ebx
  800e4c:	8b 55 08             	mov    0x8(%ebp),%edx
  800e4f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800e52:	b8 06 00 00 00       	mov    $0x6,%eax
  800e57:	89 df                	mov    %ebx,%edi
  800e59:	89 de                	mov    %ebx,%esi
  800e5b:	cd 30                	int    $0x30
	if(check && ret > 0)
  800e5d:	85 c0                	test   %eax,%eax
  800e5f:	7f 08                	jg     800e69 <sys_page_unmap+0x2f>
	return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
  800e61:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800e64:	5b                   	pop    %ebx
  800e65:	5e                   	pop    %esi
  800e66:	5f                   	pop    %edi
  800e67:	5d                   	pop    %ebp
  800e68:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  800e69:	83 ec 0c             	sub    $0xc,%esp
  800e6c:	50                   	push   %eax
  800e6d:	6a 06                	push   $0x6
  800e6f:	68 7f 28 80 00       	push   $0x80287f
  800e74:	6a 23                	push   $0x23
  800e76:	68 9c 28 80 00       	push   $0x80289c
  800e7b:	e8 2b f4 ff ff       	call   8002ab <_panic>

00800e80 <sys_env_set_status>:

// sys_exofork is inlined in lib.h

int
sys_env_set_status(envid_t envid, int status)
{
  800e80:	f3 0f 1e fb          	endbr32 
  800e84:	55                   	push   %ebp
  800e85:	89 e5                	mov    %esp,%ebp
  800e87:	57                   	push   %edi
  800e88:	56                   	push   %esi
  800e89:	53                   	push   %ebx
  800e8a:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  800e8d:	bb 00 00 00 00       	mov    $0x0,%ebx
  800e92:	8b 55 08             	mov    0x8(%ebp),%edx
  800e95:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800e98:	b8 08 00 00 00       	mov    $0x8,%eax
  800e9d:	89 df                	mov    %ebx,%edi
  800e9f:	89 de                	mov    %ebx,%esi
  800ea1:	cd 30                	int    $0x30
	if(check && ret > 0)
  800ea3:	85 c0                	test   %eax,%eax
  800ea5:	7f 08                	jg     800eaf <sys_env_set_status+0x2f>
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
  800ea7:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800eaa:	5b                   	pop    %ebx
  800eab:	5e                   	pop    %esi
  800eac:	5f                   	pop    %edi
  800ead:	5d                   	pop    %ebp
  800eae:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  800eaf:	83 ec 0c             	sub    $0xc,%esp
  800eb2:	50                   	push   %eax
  800eb3:	6a 08                	push   $0x8
  800eb5:	68 7f 28 80 00       	push   $0x80287f
  800eba:	6a 23                	push   $0x23
  800ebc:	68 9c 28 80 00       	push   $0x80289c
  800ec1:	e8 e5 f3 ff ff       	call   8002ab <_panic>

00800ec6 <sys_env_set_trapframe>:

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
  800ec6:	f3 0f 1e fb          	endbr32 
  800eca:	55                   	push   %ebp
  800ecb:	89 e5                	mov    %esp,%ebp
  800ecd:	57                   	push   %edi
  800ece:	56                   	push   %esi
  800ecf:	53                   	push   %ebx
  800ed0:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  800ed3:	bb 00 00 00 00       	mov    $0x0,%ebx
  800ed8:	8b 55 08             	mov    0x8(%ebp),%edx
  800edb:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800ede:	b8 09 00 00 00       	mov    $0x9,%eax
  800ee3:	89 df                	mov    %ebx,%edi
  800ee5:	89 de                	mov    %ebx,%esi
  800ee7:	cd 30                	int    $0x30
	if(check && ret > 0)
  800ee9:	85 c0                	test   %eax,%eax
  800eeb:	7f 08                	jg     800ef5 <sys_env_set_trapframe+0x2f>
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
  800eed:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800ef0:	5b                   	pop    %ebx
  800ef1:	5e                   	pop    %esi
  800ef2:	5f                   	pop    %edi
  800ef3:	5d                   	pop    %ebp
  800ef4:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  800ef5:	83 ec 0c             	sub    $0xc,%esp
  800ef8:	50                   	push   %eax
  800ef9:	6a 09                	push   $0x9
  800efb:	68 7f 28 80 00       	push   $0x80287f
  800f00:	6a 23                	push   $0x23
  800f02:	68 9c 28 80 00       	push   $0x80289c
  800f07:	e8 9f f3 ff ff       	call   8002ab <_panic>

00800f0c <sys_env_set_pgfault_upcall>:

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
  800f0c:	f3 0f 1e fb          	endbr32 
  800f10:	55                   	push   %ebp
  800f11:	89 e5                	mov    %esp,%ebp
  800f13:	57                   	push   %edi
  800f14:	56                   	push   %esi
  800f15:	53                   	push   %ebx
  800f16:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  800f19:	bb 00 00 00 00       	mov    $0x0,%ebx
  800f1e:	8b 55 08             	mov    0x8(%ebp),%edx
  800f21:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800f24:	b8 0a 00 00 00       	mov    $0xa,%eax
  800f29:	89 df                	mov    %ebx,%edi
  800f2b:	89 de                	mov    %ebx,%esi
  800f2d:	cd 30                	int    $0x30
	if(check && ret > 0)
  800f2f:	85 c0                	test   %eax,%eax
  800f31:	7f 08                	jg     800f3b <sys_env_set_pgfault_upcall+0x2f>
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
  800f33:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800f36:	5b                   	pop    %ebx
  800f37:	5e                   	pop    %esi
  800f38:	5f                   	pop    %edi
  800f39:	5d                   	pop    %ebp
  800f3a:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  800f3b:	83 ec 0c             	sub    $0xc,%esp
  800f3e:	50                   	push   %eax
  800f3f:	6a 0a                	push   $0xa
  800f41:	68 7f 28 80 00       	push   $0x80287f
  800f46:	6a 23                	push   $0x23
  800f48:	68 9c 28 80 00       	push   $0x80289c
  800f4d:	e8 59 f3 ff ff       	call   8002ab <_panic>

00800f52 <sys_ipc_try_send>:

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
  800f52:	f3 0f 1e fb          	endbr32 
  800f56:	55                   	push   %ebp
  800f57:	89 e5                	mov    %esp,%ebp
  800f59:	57                   	push   %edi
  800f5a:	56                   	push   %esi
  800f5b:	53                   	push   %ebx
	asm volatile("int %1\n"
  800f5c:	8b 55 08             	mov    0x8(%ebp),%edx
  800f5f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800f62:	b8 0c 00 00 00       	mov    $0xc,%eax
  800f67:	be 00 00 00 00       	mov    $0x0,%esi
  800f6c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  800f6f:	8b 7d 14             	mov    0x14(%ebp),%edi
  800f72:	cd 30                	int    $0x30
	return syscall(SYS_ipc_try_send, 0, envid, value, (uint32_t) srcva, perm, 0);
}
  800f74:	5b                   	pop    %ebx
  800f75:	5e                   	pop    %esi
  800f76:	5f                   	pop    %edi
  800f77:	5d                   	pop    %ebp
  800f78:	c3                   	ret    

00800f79 <sys_ipc_recv>:

int
sys_ipc_recv(void *dstva)
{
  800f79:	f3 0f 1e fb          	endbr32 
  800f7d:	55                   	push   %ebp
  800f7e:	89 e5                	mov    %esp,%ebp
  800f80:	57                   	push   %edi
  800f81:	56                   	push   %esi
  800f82:	53                   	push   %ebx
  800f83:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  800f86:	b9 00 00 00 00       	mov    $0x0,%ecx
  800f8b:	8b 55 08             	mov    0x8(%ebp),%edx
  800f8e:	b8 0d 00 00 00       	mov    $0xd,%eax
  800f93:	89 cb                	mov    %ecx,%ebx
  800f95:	89 cf                	mov    %ecx,%edi
  800f97:	89 ce                	mov    %ecx,%esi
  800f99:	cd 30                	int    $0x30
	if(check && ret > 0)
  800f9b:	85 c0                	test   %eax,%eax
  800f9d:	7f 08                	jg     800fa7 <sys_ipc_recv+0x2e>
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
  800f9f:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800fa2:	5b                   	pop    %ebx
  800fa3:	5e                   	pop    %esi
  800fa4:	5f                   	pop    %edi
  800fa5:	5d                   	pop    %ebp
  800fa6:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  800fa7:	83 ec 0c             	sub    $0xc,%esp
  800faa:	50                   	push   %eax
  800fab:	6a 0d                	push   $0xd
  800fad:	68 7f 28 80 00       	push   $0x80287f
  800fb2:	6a 23                	push   $0x23
  800fb4:	68 9c 28 80 00       	push   $0x80289c
  800fb9:	e8 ed f2 ff ff       	call   8002ab <_panic>

00800fbe <pgfault>:
// Custom page fault handler - if faulting page is copy-on-write,
// map in our own private writable copy.
//
static void
pgfault(struct UTrapframe *utf)
{
  800fbe:	f3 0f 1e fb          	endbr32 
  800fc2:	55                   	push   %ebp
  800fc3:	89 e5                	mov    %esp,%ebp
  800fc5:	56                   	push   %esi
  800fc6:	53                   	push   %ebx
  800fc7:	8b 45 08             	mov    0x8(%ebp),%eax
	void *addr = (void *) utf->utf_fault_va;
  800fca:	8b 18                	mov    (%eax),%ebx
	/*
	将父进程空间中所有可以写的页表的部分全部标记为可读且COW【因此读取的时候不会进入pgfault，但是写的时候会触发pgfault】。
	而当父进程或者子进程任意一个发生了写的时候，因为页表现在都是不可写的，所以会触发异常，进入到我们设定的page fault处理例程，
	当检测到是对COW页的写操作的情况下，就可以将要写入的页的内容全部拷贝一份，重新映射。
	*/
    if (!((err & FEC_WR) && (uvpd[PDX(addr)] & PTE_P) && 
  800fcc:	f6 40 04 02          	testb  $0x2,0x4(%eax)
  800fd0:	0f 84 b2 00 00 00    	je     801088 <pgfault+0xca>
  800fd6:	89 d8                	mov    %ebx,%eax
  800fd8:	c1 e8 16             	shr    $0x16,%eax
  800fdb:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  800fe2:	a8 01                	test   $0x1,%al
  800fe4:	0f 84 9e 00 00 00    	je     801088 <pgfault+0xca>
			(uvpt[PGNUM(addr)] & PTE_P) && (uvpt[PGNUM(addr)] & PTE_COW)))
  800fea:	89 d8                	mov    %ebx,%eax
  800fec:	c1 e8 0c             	shr    $0xc,%eax
  800fef:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
    if (!((err & FEC_WR) && (uvpd[PDX(addr)] & PTE_P) && 
  800ff6:	f6 c2 01             	test   $0x1,%dl
  800ff9:	0f 84 89 00 00 00    	je     801088 <pgfault+0xca>
			(uvpt[PGNUM(addr)] & PTE_P) && (uvpt[PGNUM(addr)] & PTE_COW)))
  800fff:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
    if (!((err & FEC_WR) && (uvpd[PDX(addr)] & PTE_P) && 
  801006:	f6 c4 08             	test   $0x8,%ah
  801009:	74 7d                	je     801088 <pgfault+0xca>
                panic("pgfault: it's not writable or attempt to access a non-cow page!");
	//为该进程分配新的页面。
	envid_t envid=sys_getenvid();
  80100b:	e8 57 fd ff ff       	call   800d67 <sys_getenvid>
  801010:	89 c6                	mov    %eax,%esi
	r=sys_page_alloc(envid,(void*)PFTEMP,PTE_P|PTE_U|PTE_W);
  801012:	83 ec 04             	sub    $0x4,%esp
  801015:	6a 07                	push   $0x7
  801017:	68 00 f0 7f 00       	push   $0x7ff000
  80101c:	50                   	push   %eax
  80101d:	e8 8b fd ff ff       	call   800dad <sys_page_alloc>
	if(r<0){
  801022:	83 c4 10             	add    $0x10,%esp
  801025:	85 c0                	test   %eax,%eax
  801027:	78 73                	js     80109c <pgfault+0xde>
		 panic("pgfault: page allocation failed %e", r);
	}
	//解开了我的疑惑，为什么随着fork页空间会逐渐发生偏移。
	//迁移数据过去。
	addr=ROUNDDOWN(addr,PGSIZE);
  801029:	81 e3 00 f0 ff ff    	and    $0xfffff000,%ebx
	//拷贝内容。
	memmove(PFTEMP,addr,PGSIZE);
  80102f:	83 ec 04             	sub    $0x4,%esp
  801032:	68 00 10 00 00       	push   $0x1000
  801037:	53                   	push   %ebx
  801038:	68 00 f0 7f 00       	push   $0x7ff000
  80103d:	e8 df fa ff ff       	call   800b21 <memmove>
	//解除和addr的映射关系。
	r=sys_page_unmap(envid,(void*)addr);
  801042:	83 c4 08             	add    $0x8,%esp
  801045:	53                   	push   %ebx
  801046:	56                   	push   %esi
  801047:	e8 ee fd ff ff       	call   800e3a <sys_page_unmap>
	if(r<0)
  80104c:	83 c4 10             	add    $0x10,%esp
  80104f:	85 c0                	test   %eax,%eax
  801051:	78 5b                	js     8010ae <pgfault+0xf0>
	panic("pgfault: page unmap failed %e", r);
	r=sys_page_map(envid,PFTEMP,envid,addr,PTE_P|PTE_U|PTE_W);
  801053:	83 ec 0c             	sub    $0xc,%esp
  801056:	6a 07                	push   $0x7
  801058:	53                   	push   %ebx
  801059:	56                   	push   %esi
  80105a:	68 00 f0 7f 00       	push   $0x7ff000
  80105f:	56                   	push   %esi
  801060:	e8 8f fd ff ff       	call   800df4 <sys_page_map>
	if(r<0)
  801065:	83 c4 20             	add    $0x20,%esp
  801068:	85 c0                	test   %eax,%eax
  80106a:	78 54                	js     8010c0 <pgfault+0x102>
	panic("pgfault: page map failed %e", r);
	r=sys_page_unmap(envid,PFTEMP);
  80106c:	83 ec 08             	sub    $0x8,%esp
  80106f:	68 00 f0 7f 00       	push   $0x7ff000
  801074:	56                   	push   %esi
  801075:	e8 c0 fd ff ff       	call   800e3a <sys_page_unmap>
	if(r<0)
  80107a:	83 c4 10             	add    $0x10,%esp
  80107d:	85 c0                	test   %eax,%eax
  80107f:	78 51                	js     8010d2 <pgfault+0x114>
	panic("pgfault: page unmap failed %e", r);
}
  801081:	8d 65 f8             	lea    -0x8(%ebp),%esp
  801084:	5b                   	pop    %ebx
  801085:	5e                   	pop    %esi
  801086:	5d                   	pop    %ebp
  801087:	c3                   	ret    
                panic("pgfault: it's not writable or attempt to access a non-cow page!");
  801088:	83 ec 04             	sub    $0x4,%esp
  80108b:	68 ac 28 80 00       	push   $0x8028ac
  801090:	6a 2c                	push   $0x2c
  801092:	68 5b 29 80 00       	push   $0x80295b
  801097:	e8 0f f2 ff ff       	call   8002ab <_panic>
		 panic("pgfault: page allocation failed %e", r);
  80109c:	50                   	push   %eax
  80109d:	68 ec 28 80 00       	push   $0x8028ec
  8010a2:	6a 31                	push   $0x31
  8010a4:	68 5b 29 80 00       	push   $0x80295b
  8010a9:	e8 fd f1 ff ff       	call   8002ab <_panic>
	panic("pgfault: page unmap failed %e", r);
  8010ae:	50                   	push   %eax
  8010af:	68 66 29 80 00       	push   $0x802966
  8010b4:	6a 3b                	push   $0x3b
  8010b6:	68 5b 29 80 00       	push   $0x80295b
  8010bb:	e8 eb f1 ff ff       	call   8002ab <_panic>
	panic("pgfault: page map failed %e", r);
  8010c0:	50                   	push   %eax
  8010c1:	68 84 29 80 00       	push   $0x802984
  8010c6:	6a 3e                	push   $0x3e
  8010c8:	68 5b 29 80 00       	push   $0x80295b
  8010cd:	e8 d9 f1 ff ff       	call   8002ab <_panic>
	panic("pgfault: page unmap failed %e", r);
  8010d2:	50                   	push   %eax
  8010d3:	68 66 29 80 00       	push   $0x802966
  8010d8:	6a 41                	push   $0x41
  8010da:	68 5b 29 80 00       	push   $0x80295b
  8010df:	e8 c7 f1 ff ff       	call   8002ab <_panic>

008010e4 <fork>:
//   Neither user exception stack should ever be marked copy-on-write,
//   so you must allocate a new page for the child's user exception stack.
//
envid_t
fork(void)
{
  8010e4:	f3 0f 1e fb          	endbr32 
  8010e8:	55                   	push   %ebp
  8010e9:	89 e5                	mov    %esp,%ebp
  8010eb:	57                   	push   %edi
  8010ec:	56                   	push   %esi
  8010ed:	53                   	push   %ebx
  8010ee:	83 ec 28             	sub    $0x28,%esp
	// LAB 4: Your code here.
	envid_t envid;
	uintptr_t pageVa;
	unsigned pn;
	//设置pgfault情况下对应处理的函数。
	set_pgfault_handler(pgfault);
  8010f1:	68 be 0f 80 00       	push   $0x800fbe
  8010f6:	e8 49 0f 00 00       	call   802044 <set_pgfault_handler>
// This must be inlined.  Exercise for reader: why?
static inline envid_t __attribute__((always_inline))
sys_exofork(void)
{
	envid_t ret;
	asm volatile("int %2"
  8010fb:	b8 07 00 00 00       	mov    $0x7,%eax
  801100:	cd 30                	int    $0x30
  801102:	89 c7                	mov    %eax,%edi
  801104:	89 45 e4             	mov    %eax,-0x1c(%ebp)
	//首先需要分配一个env，env_alloc是内核态调用的，因此只能去调系统调用对应的函数来请求分配一个环境描述符。
	envid=sys_exofork();
	//分配成功
	if(envid>0){
  801107:	83 c4 10             	add    $0x10,%esp
  80110a:	85 c0                	test   %eax,%eax
  80110c:	0f 8e 9d 01 00 00    	jle    8012af <fork+0x1cb>
		//接下来应该要拷贝父进程。当然这里让我吃惊的是直接可以调用对应的宏并且并没有去请求父进程。jos系统似乎是把所有的子进程都来源于同一进程，而不是父子继承关系。
		for(pageVa=UTEXT;pageVa<USTACKTOP;pageVa+=PGSIZE){
  801112:	bb 00 00 80 00       	mov    $0x800000,%ebx
  801117:	eb 5b                	jmp    801174 <fork+0x90>
			sys_page_map(0, addr, envid, addr, PTE_SYSCALL);
  801119:	83 ec 0c             	sub    $0xc,%esp
  80111c:	68 07 0e 00 00       	push   $0xe07
  801121:	56                   	push   %esi
  801122:	ff 75 e4             	pushl  -0x1c(%ebp)
  801125:	56                   	push   %esi
  801126:	6a 00                	push   $0x0
  801128:	e8 c7 fc ff ff       	call   800df4 <sys_page_map>
  80112d:	83 c4 20             	add    $0x20,%esp
  801130:	eb 30                	jmp    801162 <fork+0x7e>
                panic("duppage: sys_page_map fail\n");
  801132:	83 ec 04             	sub    $0x4,%esp
  801135:	68 a0 29 80 00       	push   $0x8029a0
  80113a:	6a 63                	push   $0x63
  80113c:	68 5b 29 80 00       	push   $0x80295b
  801141:	e8 65 f1 ff ff       	call   8002ab <_panic>
            r = sys_page_map(0, addr, envid, addr, PTE_U | PTE_P);
  801146:	83 ec 0c             	sub    $0xc,%esp
  801149:	6a 05                	push   $0x5
  80114b:	56                   	push   %esi
  80114c:	ff 75 e4             	pushl  -0x1c(%ebp)
  80114f:	56                   	push   %esi
  801150:	6a 00                	push   $0x0
  801152:	e8 9d fc ff ff       	call   800df4 <sys_page_map>
            if(r < 0)
  801157:	83 c4 20             	add    $0x20,%esp
  80115a:	85 c0                	test   %eax,%eax
  80115c:	0f 88 ac 00 00 00    	js     80120e <fork+0x12a>
		for(pageVa=UTEXT;pageVa<USTACKTOP;pageVa+=PGSIZE){
  801162:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  801168:	81 fb 00 e0 bf ee    	cmp    $0xeebfe000,%ebx
  80116e:	0f 84 ae 00 00 00    	je     801222 <fork+0x13e>
			pn=PGNUM(pageVa);
			//检查权限，挨个copy页
			if((uvpd[PDX(pageVa)]&PTE_P)&&(uvpt[pn]&PTE_P)&&(uvpt[pn]&PTE_U)){
  801174:	89 d8                	mov    %ebx,%eax
  801176:	c1 e8 16             	shr    $0x16,%eax
  801179:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  801180:	a8 01                	test   $0x1,%al
  801182:	74 de                	je     801162 <fork+0x7e>
			pn=PGNUM(pageVa);
  801184:	89 d8                	mov    %ebx,%eax
  801186:	c1 e8 0c             	shr    $0xc,%eax
			if((uvpd[PDX(pageVa)]&PTE_P)&&(uvpt[pn]&PTE_P)&&(uvpt[pn]&PTE_U)){
  801189:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
  801190:	f6 c2 01             	test   $0x1,%dl
  801193:	74 cd                	je     801162 <fork+0x7e>
  801195:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
  80119c:	f6 c2 04             	test   $0x4,%dl
  80119f:	74 c1                	je     801162 <fork+0x7e>
        addr = (void *)((uint32_t)pn * PGSIZE);
  8011a1:	89 c6                	mov    %eax,%esi
  8011a3:	c1 e6 0c             	shl    $0xc,%esi
        pte = uvpt[pn];
  8011a6:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
		if(pte&PTE_SHARE){
  8011ad:	f6 c4 04             	test   $0x4,%ah
  8011b0:	0f 85 63 ff ff ff    	jne    801119 <fork+0x35>
        else if((pte & PTE_COW) || (pte & PTE_W))
  8011b6:	a9 02 08 00 00       	test   $0x802,%eax
  8011bb:	74 89                	je     801146 <fork+0x62>
            r = sys_page_map(0, addr, envid, addr, PTE_COW | PTE_U | PTE_P);
  8011bd:	83 ec 0c             	sub    $0xc,%esp
  8011c0:	68 05 08 00 00       	push   $0x805
  8011c5:	56                   	push   %esi
  8011c6:	ff 75 e4             	pushl  -0x1c(%ebp)
  8011c9:	56                   	push   %esi
  8011ca:	6a 00                	push   $0x0
  8011cc:	e8 23 fc ff ff       	call   800df4 <sys_page_map>
            if(r < 0)
  8011d1:	83 c4 20             	add    $0x20,%esp
  8011d4:	85 c0                	test   %eax,%eax
  8011d6:	0f 88 56 ff ff ff    	js     801132 <fork+0x4e>
            r = sys_page_map(0, addr, 0, addr, PTE_COW | PTE_U | PTE_P);
  8011dc:	83 ec 0c             	sub    $0xc,%esp
  8011df:	68 05 08 00 00       	push   $0x805
  8011e4:	56                   	push   %esi
  8011e5:	6a 00                	push   $0x0
  8011e7:	56                   	push   %esi
  8011e8:	6a 00                	push   $0x0
  8011ea:	e8 05 fc ff ff       	call   800df4 <sys_page_map>
            if(r < 0)
  8011ef:	83 c4 20             	add    $0x20,%esp
  8011f2:	85 c0                	test   %eax,%eax
  8011f4:	0f 89 68 ff ff ff    	jns    801162 <fork+0x7e>
                panic("duppage: sys_page_map fail\n");
  8011fa:	83 ec 04             	sub    $0x4,%esp
  8011fd:	68 a0 29 80 00       	push   $0x8029a0
  801202:	6a 66                	push   $0x66
  801204:	68 5b 29 80 00       	push   $0x80295b
  801209:	e8 9d f0 ff ff       	call   8002ab <_panic>
                panic("duppage: sys_page_map fail\n");
  80120e:	83 ec 04             	sub    $0x4,%esp
  801211:	68 a0 29 80 00       	push   $0x8029a0
  801216:	6a 6c                	push   $0x6c
  801218:	68 5b 29 80 00       	push   $0x80295b
  80121d:	e8 89 f0 ff ff       	call   8002ab <_panic>
				duppage(envid,pn);}
			}
		//分配异常栈。
		int32_t flag=sys_page_alloc(envid,(void*)(UXSTACKTOP-PGSIZE),PTE_P|PTE_U|PTE_W);
  801222:	83 ec 04             	sub    $0x4,%esp
  801225:	6a 07                	push   $0x7
  801227:	68 00 f0 bf ee       	push   $0xeebff000
  80122c:	57                   	push   %edi
  80122d:	e8 7b fb ff ff       	call   800dad <sys_page_alloc>
		if(flag<0){
  801232:	83 c4 10             	add    $0x10,%esp
  801235:	85 c0                	test   %eax,%eax
  801237:	78 31                	js     80126a <fork+0x186>
			panic("panic by alloc page");
		}
		//设置对应的异常处理函数。
		extern void _pgfault_upcall(void);
		flag=sys_env_set_pgfault_upcall(envid,_pgfault_upcall);
  801239:	83 ec 08             	sub    $0x8,%esp
  80123c:	68 be 20 80 00       	push   $0x8020be
  801241:	57                   	push   %edi
  801242:	e8 c5 fc ff ff       	call   800f0c <sys_env_set_pgfault_upcall>
		if(flag<0){
  801247:	83 c4 10             	add    $0x10,%esp
  80124a:	85 c0                	test   %eax,%eax
  80124c:	78 33                	js     801281 <fork+0x19d>
			panic("panic by set pgfault upcall faction");
		}
		//设置子进程，等待调度。
		flag=sys_env_set_status(envid,ENV_RUNNABLE);
  80124e:	83 ec 08             	sub    $0x8,%esp
  801251:	6a 02                	push   $0x2
  801253:	57                   	push   %edi
  801254:	e8 27 fc ff ff       	call   800e80 <sys_env_set_status>
		if(flag<0){
  801259:	83 c4 10             	add    $0x10,%esp
  80125c:	85 c0                	test   %eax,%eax
  80125e:	78 38                	js     801298 <fork+0x1b4>
		//否则报错。
		panic("panic by alloc envid");
	}

	
}
  801260:	89 f8                	mov    %edi,%eax
  801262:	8d 65 f4             	lea    -0xc(%ebp),%esp
  801265:	5b                   	pop    %ebx
  801266:	5e                   	pop    %esi
  801267:	5f                   	pop    %edi
  801268:	5d                   	pop    %ebp
  801269:	c3                   	ret    
			panic("panic by alloc page");
  80126a:	83 ec 04             	sub    $0x4,%esp
  80126d:	68 bc 29 80 00       	push   $0x8029bc
  801272:	68 98 00 00 00       	push   $0x98
  801277:	68 5b 29 80 00       	push   $0x80295b
  80127c:	e8 2a f0 ff ff       	call   8002ab <_panic>
			panic("panic by set pgfault upcall faction");
  801281:	83 ec 04             	sub    $0x4,%esp
  801284:	68 10 29 80 00       	push   $0x802910
  801289:	68 9e 00 00 00       	push   $0x9e
  80128e:	68 5b 29 80 00       	push   $0x80295b
  801293:	e8 13 f0 ff ff       	call   8002ab <_panic>
			panic("panic by set env status to ENV_RUNABLE");
  801298:	83 ec 04             	sub    $0x4,%esp
  80129b:	68 34 29 80 00       	push   $0x802934
  8012a0:	68 a3 00 00 00       	push   $0xa3
  8012a5:	68 5b 29 80 00       	push   $0x80295b
  8012aa:	e8 fc ef ff ff       	call   8002ab <_panic>
	else if(envid==0){
  8012af:	75 19                	jne    8012ca <fork+0x1e6>
        thisenv = &envs[ENVX(sys_getenvid())];	//在子进程中设置thisenv为自己
  8012b1:	e8 b1 fa ff ff       	call   800d67 <sys_getenvid>
  8012b6:	25 ff 03 00 00       	and    $0x3ff,%eax
  8012bb:	6b c0 7c             	imul   $0x7c,%eax,%eax
  8012be:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  8012c3:	a3 04 40 80 00       	mov    %eax,0x804004
		return 0;
  8012c8:	eb 96                	jmp    801260 <fork+0x17c>
		panic("panic by alloc envid");
  8012ca:	83 ec 04             	sub    $0x4,%esp
  8012cd:	68 d0 29 80 00       	push   $0x8029d0
  8012d2:	68 ad 00 00 00       	push   $0xad
  8012d7:	68 5b 29 80 00       	push   $0x80295b
  8012dc:	e8 ca ef ff ff       	call   8002ab <_panic>

008012e1 <sfork>:

// Challenge!
int
sfork(void)
{
  8012e1:	f3 0f 1e fb          	endbr32 
  8012e5:	55                   	push   %ebp
  8012e6:	89 e5                	mov    %esp,%ebp
  8012e8:	83 ec 0c             	sub    $0xc,%esp
	panic("sfork not implemented");
  8012eb:	68 e5 29 80 00       	push   $0x8029e5
  8012f0:	68 b7 00 00 00       	push   $0xb7
  8012f5:	68 5b 29 80 00       	push   $0x80295b
  8012fa:	e8 ac ef ff ff       	call   8002ab <_panic>

008012ff <fd2num>:
// File descriptor manipulators
// --------------------------------------------------------------

int
fd2num(struct Fd *fd)
{
  8012ff:	f3 0f 1e fb          	endbr32 
  801303:	55                   	push   %ebp
  801304:	89 e5                	mov    %esp,%ebp
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
  801306:	8b 45 08             	mov    0x8(%ebp),%eax
  801309:	05 00 00 00 30       	add    $0x30000000,%eax
  80130e:	c1 e8 0c             	shr    $0xc,%eax
}
  801311:	5d                   	pop    %ebp
  801312:	c3                   	ret    

00801313 <fd2data>:

char*
fd2data(struct Fd *fd)
{
  801313:	f3 0f 1e fb          	endbr32 
  801317:	55                   	push   %ebp
  801318:	89 e5                	mov    %esp,%ebp
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
  80131a:	8b 45 08             	mov    0x8(%ebp),%eax
  80131d:	05 00 00 00 30       	add    $0x30000000,%eax
	return INDEX2DATA(fd2num(fd));
  801322:	25 00 f0 ff ff       	and    $0xfffff000,%eax
  801327:	2d 00 00 fe 2f       	sub    $0x2ffe0000,%eax
}
  80132c:	5d                   	pop    %ebp
  80132d:	c3                   	ret    

0080132e <fd_alloc>:
// Returns 0 on success, < 0 on error.  Errors are:
//	-E_MAX_FD: no more file descriptors
// On error, *fd_store is set to 0.
int
fd_alloc(struct Fd **fd_store)
{
  80132e:	f3 0f 1e fb          	endbr32 
  801332:	55                   	push   %ebp
  801333:	89 e5                	mov    %esp,%ebp
  801335:	b8 00 00 00 d0       	mov    $0xd0000000,%eax
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
		fd = INDEX2FD(i);
		if ((uvpd[PDX(fd)] & PTE_P) == 0 || (uvpt[PGNUM(fd)] & PTE_P) == 0) {
  80133a:	89 c2                	mov    %eax,%edx
  80133c:	c1 ea 16             	shr    $0x16,%edx
  80133f:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  801346:	f6 c2 01             	test   $0x1,%dl
  801349:	74 2d                	je     801378 <fd_alloc+0x4a>
  80134b:	89 c2                	mov    %eax,%edx
  80134d:	c1 ea 0c             	shr    $0xc,%edx
  801350:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  801357:	f6 c2 01             	test   $0x1,%dl
  80135a:	74 1c                	je     801378 <fd_alloc+0x4a>
  80135c:	05 00 10 00 00       	add    $0x1000,%eax
	for (i = 0; i < MAXFD; i++) {
  801361:	3d 00 00 02 d0       	cmp    $0xd0020000,%eax
  801366:	75 d2                	jne    80133a <fd_alloc+0xc>
			*fd_store = fd;
			return 0;
		}
	}
	*fd_store = 0;
  801368:	8b 45 08             	mov    0x8(%ebp),%eax
  80136b:	c7 00 00 00 00 00    	movl   $0x0,(%eax)
	return -E_MAX_OPEN;
  801371:	b8 f6 ff ff ff       	mov    $0xfffffff6,%eax
  801376:	eb 0a                	jmp    801382 <fd_alloc+0x54>
			*fd_store = fd;
  801378:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80137b:	89 01                	mov    %eax,(%ecx)
			return 0;
  80137d:	b8 00 00 00 00       	mov    $0x0,%eax
}
  801382:	5d                   	pop    %ebp
  801383:	c3                   	ret    

00801384 <fd_lookup>:
// Returns 0 on success (the page is in range and mapped), < 0 on error.
// Errors are:
//	-E_INVAL: fdnum was either not in range or not mapped.
int
fd_lookup(int fdnum, struct Fd **fd_store)
{
  801384:	f3 0f 1e fb          	endbr32 
  801388:	55                   	push   %ebp
  801389:	89 e5                	mov    %esp,%ebp
  80138b:	8b 45 08             	mov    0x8(%ebp),%eax
	struct Fd *fd;

	if (fdnum < 0 || fdnum >= MAXFD) {
  80138e:	83 f8 1f             	cmp    $0x1f,%eax
  801391:	77 30                	ja     8013c3 <fd_lookup+0x3f>
		if (debug)
			cprintf("[%08x] bad fd %d\n", thisenv->env_id, fdnum);
		return -E_INVAL;
	}
	fd = INDEX2FD(fdnum);
  801393:	c1 e0 0c             	shl    $0xc,%eax
  801396:	2d 00 00 00 30       	sub    $0x30000000,%eax
	if (!(uvpd[PDX(fd)] & PTE_P) || !(uvpt[PGNUM(fd)] & PTE_P)) {
  80139b:	8b 15 00 dd 7b ef    	mov    0xef7bdd00,%edx
  8013a1:	f6 c2 01             	test   $0x1,%dl
  8013a4:	74 24                	je     8013ca <fd_lookup+0x46>
  8013a6:	89 c2                	mov    %eax,%edx
  8013a8:	c1 ea 0c             	shr    $0xc,%edx
  8013ab:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  8013b2:	f6 c2 01             	test   $0x1,%dl
  8013b5:	74 1a                	je     8013d1 <fd_lookup+0x4d>
		if (debug)
			cprintf("[%08x] closed fd %d\n", thisenv->env_id, fdnum);
		return -E_INVAL;
	}
	*fd_store = fd;
  8013b7:	8b 55 0c             	mov    0xc(%ebp),%edx
  8013ba:	89 02                	mov    %eax,(%edx)
	return 0;
  8013bc:	b8 00 00 00 00       	mov    $0x0,%eax
}
  8013c1:	5d                   	pop    %ebp
  8013c2:	c3                   	ret    
		return -E_INVAL;
  8013c3:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  8013c8:	eb f7                	jmp    8013c1 <fd_lookup+0x3d>
		return -E_INVAL;
  8013ca:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  8013cf:	eb f0                	jmp    8013c1 <fd_lookup+0x3d>
  8013d1:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  8013d6:	eb e9                	jmp    8013c1 <fd_lookup+0x3d>

008013d8 <dev_lookup>:
	0
};

int
dev_lookup(int dev_id, struct Dev **dev)
{
  8013d8:	f3 0f 1e fb          	endbr32 
  8013dc:	55                   	push   %ebp
  8013dd:	89 e5                	mov    %esp,%ebp
  8013df:	83 ec 08             	sub    $0x8,%esp
  8013e2:	8b 4d 08             	mov    0x8(%ebp),%ecx
  8013e5:	ba 78 2a 80 00       	mov    $0x802a78,%edx
	int i;
	for (i = 0; devtab[i]; i++)
  8013ea:	b8 04 30 80 00       	mov    $0x803004,%eax
		if (devtab[i]->dev_id == dev_id) {
  8013ef:	39 08                	cmp    %ecx,(%eax)
  8013f1:	74 33                	je     801426 <dev_lookup+0x4e>
  8013f3:	83 c2 04             	add    $0x4,%edx
	for (i = 0; devtab[i]; i++)
  8013f6:	8b 02                	mov    (%edx),%eax
  8013f8:	85 c0                	test   %eax,%eax
  8013fa:	75 f3                	jne    8013ef <dev_lookup+0x17>
			*dev = devtab[i];
			return 0;
		}
	cprintf("[%08x] unknown device type %d\n", thisenv->env_id, dev_id);
  8013fc:	a1 04 40 80 00       	mov    0x804004,%eax
  801401:	8b 40 48             	mov    0x48(%eax),%eax
  801404:	83 ec 04             	sub    $0x4,%esp
  801407:	51                   	push   %ecx
  801408:	50                   	push   %eax
  801409:	68 fc 29 80 00       	push   $0x8029fc
  80140e:	e8 7f ef ff ff       	call   800392 <cprintf>
	*dev = 0;
  801413:	8b 45 0c             	mov    0xc(%ebp),%eax
  801416:	c7 00 00 00 00 00    	movl   $0x0,(%eax)
	return -E_INVAL;
  80141c:	83 c4 10             	add    $0x10,%esp
  80141f:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  801424:	c9                   	leave  
  801425:	c3                   	ret    
			*dev = devtab[i];
  801426:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801429:	89 01                	mov    %eax,(%ecx)
			return 0;
  80142b:	b8 00 00 00 00       	mov    $0x0,%eax
  801430:	eb f2                	jmp    801424 <dev_lookup+0x4c>

00801432 <fd_close>:
{
  801432:	f3 0f 1e fb          	endbr32 
  801436:	55                   	push   %ebp
  801437:	89 e5                	mov    %esp,%ebp
  801439:	57                   	push   %edi
  80143a:	56                   	push   %esi
  80143b:	53                   	push   %ebx
  80143c:	83 ec 24             	sub    $0x24,%esp
  80143f:	8b 75 08             	mov    0x8(%ebp),%esi
  801442:	8b 7d 0c             	mov    0xc(%ebp),%edi
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  801445:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  801448:	50                   	push   %eax
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
  801449:	8d 86 00 00 00 30    	lea    0x30000000(%esi),%eax
  80144f:	c1 e8 0c             	shr    $0xc,%eax
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  801452:	50                   	push   %eax
  801453:	e8 2c ff ff ff       	call   801384 <fd_lookup>
  801458:	89 c3                	mov    %eax,%ebx
  80145a:	83 c4 10             	add    $0x10,%esp
  80145d:	85 c0                	test   %eax,%eax
  80145f:	78 05                	js     801466 <fd_close+0x34>
	    || fd != fd2)
  801461:	39 75 e4             	cmp    %esi,-0x1c(%ebp)
  801464:	74 16                	je     80147c <fd_close+0x4a>
		return (must_exist ? r : 0);
  801466:	89 f8                	mov    %edi,%eax
  801468:	84 c0                	test   %al,%al
  80146a:	b8 00 00 00 00       	mov    $0x0,%eax
  80146f:	0f 44 d8             	cmove  %eax,%ebx
}
  801472:	89 d8                	mov    %ebx,%eax
  801474:	8d 65 f4             	lea    -0xc(%ebp),%esp
  801477:	5b                   	pop    %ebx
  801478:	5e                   	pop    %esi
  801479:	5f                   	pop    %edi
  80147a:	5d                   	pop    %ebp
  80147b:	c3                   	ret    
	if ((r = dev_lookup(fd->fd_dev_id, &dev)) >= 0) {
  80147c:	83 ec 08             	sub    $0x8,%esp
  80147f:	8d 45 e0             	lea    -0x20(%ebp),%eax
  801482:	50                   	push   %eax
  801483:	ff 36                	pushl  (%esi)
  801485:	e8 4e ff ff ff       	call   8013d8 <dev_lookup>
  80148a:	89 c3                	mov    %eax,%ebx
  80148c:	83 c4 10             	add    $0x10,%esp
  80148f:	85 c0                	test   %eax,%eax
  801491:	78 1a                	js     8014ad <fd_close+0x7b>
		if (dev->dev_close)
  801493:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801496:	8b 40 10             	mov    0x10(%eax),%eax
			r = 0;
  801499:	bb 00 00 00 00       	mov    $0x0,%ebx
		if (dev->dev_close)
  80149e:	85 c0                	test   %eax,%eax
  8014a0:	74 0b                	je     8014ad <fd_close+0x7b>
			r = (*dev->dev_close)(fd);
  8014a2:	83 ec 0c             	sub    $0xc,%esp
  8014a5:	56                   	push   %esi
  8014a6:	ff d0                	call   *%eax
  8014a8:	89 c3                	mov    %eax,%ebx
  8014aa:	83 c4 10             	add    $0x10,%esp
	(void) sys_page_unmap(0, fd);
  8014ad:	83 ec 08             	sub    $0x8,%esp
  8014b0:	56                   	push   %esi
  8014b1:	6a 00                	push   $0x0
  8014b3:	e8 82 f9 ff ff       	call   800e3a <sys_page_unmap>
	return r;
  8014b8:	83 c4 10             	add    $0x10,%esp
  8014bb:	eb b5                	jmp    801472 <fd_close+0x40>

008014bd <close>:

int
close(int fdnum)
{
  8014bd:	f3 0f 1e fb          	endbr32 
  8014c1:	55                   	push   %ebp
  8014c2:	89 e5                	mov    %esp,%ebp
  8014c4:	83 ec 20             	sub    $0x20,%esp
	struct Fd *fd;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  8014c7:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8014ca:	50                   	push   %eax
  8014cb:	ff 75 08             	pushl  0x8(%ebp)
  8014ce:	e8 b1 fe ff ff       	call   801384 <fd_lookup>
  8014d3:	83 c4 10             	add    $0x10,%esp
  8014d6:	85 c0                	test   %eax,%eax
  8014d8:	79 02                	jns    8014dc <close+0x1f>
		return r;
	else
		return fd_close(fd, 1);
}
  8014da:	c9                   	leave  
  8014db:	c3                   	ret    
		return fd_close(fd, 1);
  8014dc:	83 ec 08             	sub    $0x8,%esp
  8014df:	6a 01                	push   $0x1
  8014e1:	ff 75 f4             	pushl  -0xc(%ebp)
  8014e4:	e8 49 ff ff ff       	call   801432 <fd_close>
  8014e9:	83 c4 10             	add    $0x10,%esp
  8014ec:	eb ec                	jmp    8014da <close+0x1d>

008014ee <close_all>:

void
close_all(void)
{
  8014ee:	f3 0f 1e fb          	endbr32 
  8014f2:	55                   	push   %ebp
  8014f3:	89 e5                	mov    %esp,%ebp
  8014f5:	53                   	push   %ebx
  8014f6:	83 ec 04             	sub    $0x4,%esp
	int i;
	for (i = 0; i < MAXFD; i++)
  8014f9:	bb 00 00 00 00       	mov    $0x0,%ebx
		close(i);
  8014fe:	83 ec 0c             	sub    $0xc,%esp
  801501:	53                   	push   %ebx
  801502:	e8 b6 ff ff ff       	call   8014bd <close>
	for (i = 0; i < MAXFD; i++)
  801507:	83 c3 01             	add    $0x1,%ebx
  80150a:	83 c4 10             	add    $0x10,%esp
  80150d:	83 fb 20             	cmp    $0x20,%ebx
  801510:	75 ec                	jne    8014fe <close_all+0x10>
}
  801512:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  801515:	c9                   	leave  
  801516:	c3                   	ret    

00801517 <dup>:
// file and the file offset of the other.
// Closes any previously open file descriptor at 'newfdnum'.
// This is implemented using virtual memory tricks (of course!).
int
dup(int oldfdnum, int newfdnum)
{
  801517:	f3 0f 1e fb          	endbr32 
  80151b:	55                   	push   %ebp
  80151c:	89 e5                	mov    %esp,%ebp
  80151e:	57                   	push   %edi
  80151f:	56                   	push   %esi
  801520:	53                   	push   %ebx
  801521:	83 ec 24             	sub    $0x24,%esp
	int r;
	char *ova, *nva;
	pte_t pte;
	struct Fd *oldfd, *newfd;

	if ((r = fd_lookup(oldfdnum, &oldfd)) < 0)
  801524:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  801527:	50                   	push   %eax
  801528:	ff 75 08             	pushl  0x8(%ebp)
  80152b:	e8 54 fe ff ff       	call   801384 <fd_lookup>
  801530:	89 c3                	mov    %eax,%ebx
  801532:	83 c4 10             	add    $0x10,%esp
  801535:	85 c0                	test   %eax,%eax
  801537:	0f 88 81 00 00 00    	js     8015be <dup+0xa7>
		return r;
	close(newfdnum);
  80153d:	83 ec 0c             	sub    $0xc,%esp
  801540:	ff 75 0c             	pushl  0xc(%ebp)
  801543:	e8 75 ff ff ff       	call   8014bd <close>

	newfd = INDEX2FD(newfdnum);
  801548:	8b 75 0c             	mov    0xc(%ebp),%esi
  80154b:	c1 e6 0c             	shl    $0xc,%esi
  80154e:	81 ee 00 00 00 30    	sub    $0x30000000,%esi
	ova = fd2data(oldfd);
  801554:	83 c4 04             	add    $0x4,%esp
  801557:	ff 75 e4             	pushl  -0x1c(%ebp)
  80155a:	e8 b4 fd ff ff       	call   801313 <fd2data>
  80155f:	89 c3                	mov    %eax,%ebx
	nva = fd2data(newfd);
  801561:	89 34 24             	mov    %esi,(%esp)
  801564:	e8 aa fd ff ff       	call   801313 <fd2data>
  801569:	83 c4 10             	add    $0x10,%esp
  80156c:	89 c7                	mov    %eax,%edi

	if ((uvpd[PDX(ova)] & PTE_P) && (uvpt[PGNUM(ova)] & PTE_P))
  80156e:	89 d8                	mov    %ebx,%eax
  801570:	c1 e8 16             	shr    $0x16,%eax
  801573:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  80157a:	a8 01                	test   $0x1,%al
  80157c:	74 11                	je     80158f <dup+0x78>
  80157e:	89 d8                	mov    %ebx,%eax
  801580:	c1 e8 0c             	shr    $0xc,%eax
  801583:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
  80158a:	f6 c2 01             	test   $0x1,%dl
  80158d:	75 39                	jne    8015c8 <dup+0xb1>
		if ((r = sys_page_map(0, ova, 0, nva, uvpt[PGNUM(ova)] & PTE_SYSCALL)) < 0)
			goto err;
	if ((r = sys_page_map(0, oldfd, 0, newfd, uvpt[PGNUM(oldfd)] & PTE_SYSCALL)) < 0)
  80158f:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  801592:	89 d0                	mov    %edx,%eax
  801594:	c1 e8 0c             	shr    $0xc,%eax
  801597:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  80159e:	83 ec 0c             	sub    $0xc,%esp
  8015a1:	25 07 0e 00 00       	and    $0xe07,%eax
  8015a6:	50                   	push   %eax
  8015a7:	56                   	push   %esi
  8015a8:	6a 00                	push   $0x0
  8015aa:	52                   	push   %edx
  8015ab:	6a 00                	push   $0x0
  8015ad:	e8 42 f8 ff ff       	call   800df4 <sys_page_map>
  8015b2:	89 c3                	mov    %eax,%ebx
  8015b4:	83 c4 20             	add    $0x20,%esp
  8015b7:	85 c0                	test   %eax,%eax
  8015b9:	78 31                	js     8015ec <dup+0xd5>
		goto err;

	return newfdnum;
  8015bb:	8b 5d 0c             	mov    0xc(%ebp),%ebx

err:
	sys_page_unmap(0, newfd);
	sys_page_unmap(0, nva);
	return r;
}
  8015be:	89 d8                	mov    %ebx,%eax
  8015c0:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8015c3:	5b                   	pop    %ebx
  8015c4:	5e                   	pop    %esi
  8015c5:	5f                   	pop    %edi
  8015c6:	5d                   	pop    %ebp
  8015c7:	c3                   	ret    
		if ((r = sys_page_map(0, ova, 0, nva, uvpt[PGNUM(ova)] & PTE_SYSCALL)) < 0)
  8015c8:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  8015cf:	83 ec 0c             	sub    $0xc,%esp
  8015d2:	25 07 0e 00 00       	and    $0xe07,%eax
  8015d7:	50                   	push   %eax
  8015d8:	57                   	push   %edi
  8015d9:	6a 00                	push   $0x0
  8015db:	53                   	push   %ebx
  8015dc:	6a 00                	push   $0x0
  8015de:	e8 11 f8 ff ff       	call   800df4 <sys_page_map>
  8015e3:	89 c3                	mov    %eax,%ebx
  8015e5:	83 c4 20             	add    $0x20,%esp
  8015e8:	85 c0                	test   %eax,%eax
  8015ea:	79 a3                	jns    80158f <dup+0x78>
	sys_page_unmap(0, newfd);
  8015ec:	83 ec 08             	sub    $0x8,%esp
  8015ef:	56                   	push   %esi
  8015f0:	6a 00                	push   $0x0
  8015f2:	e8 43 f8 ff ff       	call   800e3a <sys_page_unmap>
	sys_page_unmap(0, nva);
  8015f7:	83 c4 08             	add    $0x8,%esp
  8015fa:	57                   	push   %edi
  8015fb:	6a 00                	push   $0x0
  8015fd:	e8 38 f8 ff ff       	call   800e3a <sys_page_unmap>
	return r;
  801602:	83 c4 10             	add    $0x10,%esp
  801605:	eb b7                	jmp    8015be <dup+0xa7>

00801607 <read>:

ssize_t
read(int fdnum, void *buf, size_t n)
{
  801607:	f3 0f 1e fb          	endbr32 
  80160b:	55                   	push   %ebp
  80160c:	89 e5                	mov    %esp,%ebp
  80160e:	53                   	push   %ebx
  80160f:	83 ec 1c             	sub    $0x1c,%esp
  801612:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801615:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801618:	50                   	push   %eax
  801619:	53                   	push   %ebx
  80161a:	e8 65 fd ff ff       	call   801384 <fd_lookup>
  80161f:	83 c4 10             	add    $0x10,%esp
  801622:	85 c0                	test   %eax,%eax
  801624:	78 3f                	js     801665 <read+0x5e>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801626:	83 ec 08             	sub    $0x8,%esp
  801629:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80162c:	50                   	push   %eax
  80162d:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801630:	ff 30                	pushl  (%eax)
  801632:	e8 a1 fd ff ff       	call   8013d8 <dev_lookup>
  801637:	83 c4 10             	add    $0x10,%esp
  80163a:	85 c0                	test   %eax,%eax
  80163c:	78 27                	js     801665 <read+0x5e>
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_WRONLY) {
  80163e:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801641:	8b 42 08             	mov    0x8(%edx),%eax
  801644:	83 e0 03             	and    $0x3,%eax
  801647:	83 f8 01             	cmp    $0x1,%eax
  80164a:	74 1e                	je     80166a <read+0x63>
		cprintf("[%08x] read %d -- bad mode\n", thisenv->env_id, fdnum);
		return -E_INVAL;
	}
	if (!dev->dev_read)
  80164c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80164f:	8b 40 08             	mov    0x8(%eax),%eax
  801652:	85 c0                	test   %eax,%eax
  801654:	74 35                	je     80168b <read+0x84>
		return -E_NOT_SUPP;
	return (*dev->dev_read)(fd, buf, n);
  801656:	83 ec 04             	sub    $0x4,%esp
  801659:	ff 75 10             	pushl  0x10(%ebp)
  80165c:	ff 75 0c             	pushl  0xc(%ebp)
  80165f:	52                   	push   %edx
  801660:	ff d0                	call   *%eax
  801662:	83 c4 10             	add    $0x10,%esp
}
  801665:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  801668:	c9                   	leave  
  801669:	c3                   	ret    
		cprintf("[%08x] read %d -- bad mode\n", thisenv->env_id, fdnum);
  80166a:	a1 04 40 80 00       	mov    0x804004,%eax
  80166f:	8b 40 48             	mov    0x48(%eax),%eax
  801672:	83 ec 04             	sub    $0x4,%esp
  801675:	53                   	push   %ebx
  801676:	50                   	push   %eax
  801677:	68 3d 2a 80 00       	push   $0x802a3d
  80167c:	e8 11 ed ff ff       	call   800392 <cprintf>
		return -E_INVAL;
  801681:	83 c4 10             	add    $0x10,%esp
  801684:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  801689:	eb da                	jmp    801665 <read+0x5e>
		return -E_NOT_SUPP;
  80168b:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801690:	eb d3                	jmp    801665 <read+0x5e>

00801692 <readn>:

ssize_t
readn(int fdnum, void *buf, size_t n)
{
  801692:	f3 0f 1e fb          	endbr32 
  801696:	55                   	push   %ebp
  801697:	89 e5                	mov    %esp,%ebp
  801699:	57                   	push   %edi
  80169a:	56                   	push   %esi
  80169b:	53                   	push   %ebx
  80169c:	83 ec 0c             	sub    $0xc,%esp
  80169f:	8b 7d 08             	mov    0x8(%ebp),%edi
  8016a2:	8b 75 10             	mov    0x10(%ebp),%esi
	int m, tot;

	for (tot = 0; tot < n; tot += m) {
  8016a5:	bb 00 00 00 00       	mov    $0x0,%ebx
  8016aa:	eb 02                	jmp    8016ae <readn+0x1c>
  8016ac:	01 c3                	add    %eax,%ebx
  8016ae:	39 f3                	cmp    %esi,%ebx
  8016b0:	73 21                	jae    8016d3 <readn+0x41>
		m = read(fdnum, (char*)buf + tot, n - tot);
  8016b2:	83 ec 04             	sub    $0x4,%esp
  8016b5:	89 f0                	mov    %esi,%eax
  8016b7:	29 d8                	sub    %ebx,%eax
  8016b9:	50                   	push   %eax
  8016ba:	89 d8                	mov    %ebx,%eax
  8016bc:	03 45 0c             	add    0xc(%ebp),%eax
  8016bf:	50                   	push   %eax
  8016c0:	57                   	push   %edi
  8016c1:	e8 41 ff ff ff       	call   801607 <read>
		if (m < 0)
  8016c6:	83 c4 10             	add    $0x10,%esp
  8016c9:	85 c0                	test   %eax,%eax
  8016cb:	78 04                	js     8016d1 <readn+0x3f>
			return m;
		if (m == 0)
  8016cd:	75 dd                	jne    8016ac <readn+0x1a>
  8016cf:	eb 02                	jmp    8016d3 <readn+0x41>
		m = read(fdnum, (char*)buf + tot, n - tot);
  8016d1:	89 c3                	mov    %eax,%ebx
			break;
	}
	return tot;
}
  8016d3:	89 d8                	mov    %ebx,%eax
  8016d5:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8016d8:	5b                   	pop    %ebx
  8016d9:	5e                   	pop    %esi
  8016da:	5f                   	pop    %edi
  8016db:	5d                   	pop    %ebp
  8016dc:	c3                   	ret    

008016dd <write>:

ssize_t
write(int fdnum, const void *buf, size_t n)
{
  8016dd:	f3 0f 1e fb          	endbr32 
  8016e1:	55                   	push   %ebp
  8016e2:	89 e5                	mov    %esp,%ebp
  8016e4:	53                   	push   %ebx
  8016e5:	83 ec 1c             	sub    $0x1c,%esp
  8016e8:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8016eb:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8016ee:	50                   	push   %eax
  8016ef:	53                   	push   %ebx
  8016f0:	e8 8f fc ff ff       	call   801384 <fd_lookup>
  8016f5:	83 c4 10             	add    $0x10,%esp
  8016f8:	85 c0                	test   %eax,%eax
  8016fa:	78 3a                	js     801736 <write+0x59>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  8016fc:	83 ec 08             	sub    $0x8,%esp
  8016ff:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801702:	50                   	push   %eax
  801703:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801706:	ff 30                	pushl  (%eax)
  801708:	e8 cb fc ff ff       	call   8013d8 <dev_lookup>
  80170d:	83 c4 10             	add    $0x10,%esp
  801710:	85 c0                	test   %eax,%eax
  801712:	78 22                	js     801736 <write+0x59>
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  801714:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801717:	f6 40 08 03          	testb  $0x3,0x8(%eax)
  80171b:	74 1e                	je     80173b <write+0x5e>
		return -E_INVAL;
	}
	if (debug)
		cprintf("write %d %p %d via dev %s\n",
			fdnum, buf, n, dev->dev_name);
	if (!dev->dev_write)
  80171d:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801720:	8b 52 0c             	mov    0xc(%edx),%edx
  801723:	85 d2                	test   %edx,%edx
  801725:	74 35                	je     80175c <write+0x7f>
		return -E_NOT_SUPP;
	return (*dev->dev_write)(fd, buf, n);
  801727:	83 ec 04             	sub    $0x4,%esp
  80172a:	ff 75 10             	pushl  0x10(%ebp)
  80172d:	ff 75 0c             	pushl  0xc(%ebp)
  801730:	50                   	push   %eax
  801731:	ff d2                	call   *%edx
  801733:	83 c4 10             	add    $0x10,%esp
}
  801736:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  801739:	c9                   	leave  
  80173a:	c3                   	ret    
		cprintf("[%08x] write %d -- bad mode\n", thisenv->env_id, fdnum);
  80173b:	a1 04 40 80 00       	mov    0x804004,%eax
  801740:	8b 40 48             	mov    0x48(%eax),%eax
  801743:	83 ec 04             	sub    $0x4,%esp
  801746:	53                   	push   %ebx
  801747:	50                   	push   %eax
  801748:	68 59 2a 80 00       	push   $0x802a59
  80174d:	e8 40 ec ff ff       	call   800392 <cprintf>
		return -E_INVAL;
  801752:	83 c4 10             	add    $0x10,%esp
  801755:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  80175a:	eb da                	jmp    801736 <write+0x59>
		return -E_NOT_SUPP;
  80175c:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801761:	eb d3                	jmp    801736 <write+0x59>

00801763 <seek>:

int
seek(int fdnum, off_t offset)
{
  801763:	f3 0f 1e fb          	endbr32 
  801767:	55                   	push   %ebp
  801768:	89 e5                	mov    %esp,%ebp
  80176a:	83 ec 20             	sub    $0x20,%esp
	int r;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  80176d:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801770:	50                   	push   %eax
  801771:	ff 75 08             	pushl  0x8(%ebp)
  801774:	e8 0b fc ff ff       	call   801384 <fd_lookup>
  801779:	83 c4 10             	add    $0x10,%esp
  80177c:	85 c0                	test   %eax,%eax
  80177e:	78 0e                	js     80178e <seek+0x2b>
		return r;
	fd->fd_offset = offset;
  801780:	8b 55 0c             	mov    0xc(%ebp),%edx
  801783:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801786:	89 50 04             	mov    %edx,0x4(%eax)
	return 0;
  801789:	b8 00 00 00 00       	mov    $0x0,%eax
}
  80178e:	c9                   	leave  
  80178f:	c3                   	ret    

00801790 <ftruncate>:

int
ftruncate(int fdnum, off_t newsize)
{
  801790:	f3 0f 1e fb          	endbr32 
  801794:	55                   	push   %ebp
  801795:	89 e5                	mov    %esp,%ebp
  801797:	53                   	push   %ebx
  801798:	83 ec 1c             	sub    $0x1c,%esp
  80179b:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  80179e:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8017a1:	50                   	push   %eax
  8017a2:	53                   	push   %ebx
  8017a3:	e8 dc fb ff ff       	call   801384 <fd_lookup>
  8017a8:	83 c4 10             	add    $0x10,%esp
  8017ab:	85 c0                	test   %eax,%eax
  8017ad:	78 37                	js     8017e6 <ftruncate+0x56>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  8017af:	83 ec 08             	sub    $0x8,%esp
  8017b2:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8017b5:	50                   	push   %eax
  8017b6:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8017b9:	ff 30                	pushl  (%eax)
  8017bb:	e8 18 fc ff ff       	call   8013d8 <dev_lookup>
  8017c0:	83 c4 10             	add    $0x10,%esp
  8017c3:	85 c0                	test   %eax,%eax
  8017c5:	78 1f                	js     8017e6 <ftruncate+0x56>
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  8017c7:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8017ca:	f6 40 08 03          	testb  $0x3,0x8(%eax)
  8017ce:	74 1b                	je     8017eb <ftruncate+0x5b>
		cprintf("[%08x] ftruncate %d -- bad mode\n",
			thisenv->env_id, fdnum);
		return -E_INVAL;
	}
	if (!dev->dev_trunc)
  8017d0:	8b 55 f4             	mov    -0xc(%ebp),%edx
  8017d3:	8b 52 18             	mov    0x18(%edx),%edx
  8017d6:	85 d2                	test   %edx,%edx
  8017d8:	74 32                	je     80180c <ftruncate+0x7c>
		return -E_NOT_SUPP;
	return (*dev->dev_trunc)(fd, newsize);
  8017da:	83 ec 08             	sub    $0x8,%esp
  8017dd:	ff 75 0c             	pushl  0xc(%ebp)
  8017e0:	50                   	push   %eax
  8017e1:	ff d2                	call   *%edx
  8017e3:	83 c4 10             	add    $0x10,%esp
}
  8017e6:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  8017e9:	c9                   	leave  
  8017ea:	c3                   	ret    
			thisenv->env_id, fdnum);
  8017eb:	a1 04 40 80 00       	mov    0x804004,%eax
		cprintf("[%08x] ftruncate %d -- bad mode\n",
  8017f0:	8b 40 48             	mov    0x48(%eax),%eax
  8017f3:	83 ec 04             	sub    $0x4,%esp
  8017f6:	53                   	push   %ebx
  8017f7:	50                   	push   %eax
  8017f8:	68 1c 2a 80 00       	push   $0x802a1c
  8017fd:	e8 90 eb ff ff       	call   800392 <cprintf>
		return -E_INVAL;
  801802:	83 c4 10             	add    $0x10,%esp
  801805:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  80180a:	eb da                	jmp    8017e6 <ftruncate+0x56>
		return -E_NOT_SUPP;
  80180c:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801811:	eb d3                	jmp    8017e6 <ftruncate+0x56>

00801813 <fstat>:

int
fstat(int fdnum, struct Stat *stat)
{
  801813:	f3 0f 1e fb          	endbr32 
  801817:	55                   	push   %ebp
  801818:	89 e5                	mov    %esp,%ebp
  80181a:	53                   	push   %ebx
  80181b:	83 ec 1c             	sub    $0x1c,%esp
  80181e:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801821:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801824:	50                   	push   %eax
  801825:	ff 75 08             	pushl  0x8(%ebp)
  801828:	e8 57 fb ff ff       	call   801384 <fd_lookup>
  80182d:	83 c4 10             	add    $0x10,%esp
  801830:	85 c0                	test   %eax,%eax
  801832:	78 4b                	js     80187f <fstat+0x6c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801834:	83 ec 08             	sub    $0x8,%esp
  801837:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80183a:	50                   	push   %eax
  80183b:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80183e:	ff 30                	pushl  (%eax)
  801840:	e8 93 fb ff ff       	call   8013d8 <dev_lookup>
  801845:	83 c4 10             	add    $0x10,%esp
  801848:	85 c0                	test   %eax,%eax
  80184a:	78 33                	js     80187f <fstat+0x6c>
		return r;
	if (!dev->dev_stat)
  80184c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80184f:	83 78 14 00          	cmpl   $0x0,0x14(%eax)
  801853:	74 2f                	je     801884 <fstat+0x71>
		return -E_NOT_SUPP;
	stat->st_name[0] = 0;
  801855:	c6 03 00             	movb   $0x0,(%ebx)
	stat->st_size = 0;
  801858:	c7 83 80 00 00 00 00 	movl   $0x0,0x80(%ebx)
  80185f:	00 00 00 
	stat->st_isdir = 0;
  801862:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  801869:	00 00 00 
	stat->st_dev = dev;
  80186c:	89 83 88 00 00 00    	mov    %eax,0x88(%ebx)
	return (*dev->dev_stat)(fd, stat);
  801872:	83 ec 08             	sub    $0x8,%esp
  801875:	53                   	push   %ebx
  801876:	ff 75 f0             	pushl  -0x10(%ebp)
  801879:	ff 50 14             	call   *0x14(%eax)
  80187c:	83 c4 10             	add    $0x10,%esp
}
  80187f:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  801882:	c9                   	leave  
  801883:	c3                   	ret    
		return -E_NOT_SUPP;
  801884:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801889:	eb f4                	jmp    80187f <fstat+0x6c>

0080188b <stat>:

int
stat(const char *path, struct Stat *stat)
{
  80188b:	f3 0f 1e fb          	endbr32 
  80188f:	55                   	push   %ebp
  801890:	89 e5                	mov    %esp,%ebp
  801892:	56                   	push   %esi
  801893:	53                   	push   %ebx
	int fd, r;

	if ((fd = open(path, O_RDONLY)) < 0)
  801894:	83 ec 08             	sub    $0x8,%esp
  801897:	6a 00                	push   $0x0
  801899:	ff 75 08             	pushl  0x8(%ebp)
  80189c:	e8 fb 01 00 00       	call   801a9c <open>
  8018a1:	89 c3                	mov    %eax,%ebx
  8018a3:	83 c4 10             	add    $0x10,%esp
  8018a6:	85 c0                	test   %eax,%eax
  8018a8:	78 1b                	js     8018c5 <stat+0x3a>
		return fd;
	r = fstat(fd, stat);
  8018aa:	83 ec 08             	sub    $0x8,%esp
  8018ad:	ff 75 0c             	pushl  0xc(%ebp)
  8018b0:	50                   	push   %eax
  8018b1:	e8 5d ff ff ff       	call   801813 <fstat>
  8018b6:	89 c6                	mov    %eax,%esi
	close(fd);
  8018b8:	89 1c 24             	mov    %ebx,(%esp)
  8018bb:	e8 fd fb ff ff       	call   8014bd <close>
	return r;
  8018c0:	83 c4 10             	add    $0x10,%esp
  8018c3:	89 f3                	mov    %esi,%ebx
}
  8018c5:	89 d8                	mov    %ebx,%eax
  8018c7:	8d 65 f8             	lea    -0x8(%ebp),%esp
  8018ca:	5b                   	pop    %ebx
  8018cb:	5e                   	pop    %esi
  8018cc:	5d                   	pop    %ebp
  8018cd:	c3                   	ret    

008018ce <fsipc>:
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
  8018ce:	55                   	push   %ebp
  8018cf:	89 e5                	mov    %esp,%ebp
  8018d1:	56                   	push   %esi
  8018d2:	53                   	push   %ebx
  8018d3:	89 c6                	mov    %eax,%esi
  8018d5:	89 d3                	mov    %edx,%ebx
	static envid_t fsenv;
	if (fsenv == 0)
  8018d7:	83 3d 00 40 80 00 00 	cmpl   $0x0,0x804000
  8018de:	74 27                	je     801907 <fsipc+0x39>
	static_assert(sizeof(fsipcbuf) == PGSIZE);

	if (debug)
		cprintf("[%08x] fsipc %d %08x\n", thisenv->env_id, type, *(uint32_t *)&fsipcbuf);

	ipc_send(fsenv, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
  8018e0:	6a 07                	push   $0x7
  8018e2:	68 00 50 80 00       	push   $0x805000
  8018e7:	56                   	push   %esi
  8018e8:	ff 35 00 40 80 00    	pushl  0x804000
  8018ee:	e8 73 08 00 00       	call   802166 <ipc_send>
	return ipc_recv(NULL, dstva, NULL);
  8018f3:	83 c4 0c             	add    $0xc,%esp
  8018f6:	6a 00                	push   $0x0
  8018f8:	53                   	push   %ebx
  8018f9:	6a 00                	push   $0x0
  8018fb:	e8 e5 07 00 00       	call   8020e5 <ipc_recv>
}
  801900:	8d 65 f8             	lea    -0x8(%ebp),%esp
  801903:	5b                   	pop    %ebx
  801904:	5e                   	pop    %esi
  801905:	5d                   	pop    %ebp
  801906:	c3                   	ret    
		fsenv = ipc_find_env(ENV_TYPE_FS);
  801907:	83 ec 0c             	sub    $0xc,%esp
  80190a:	6a 01                	push   $0x1
  80190c:	e8 ad 08 00 00       	call   8021be <ipc_find_env>
  801911:	a3 00 40 80 00       	mov    %eax,0x804000
  801916:	83 c4 10             	add    $0x10,%esp
  801919:	eb c5                	jmp    8018e0 <fsipc+0x12>

0080191b <devfile_trunc>:
}

// Truncate or extend an open file to 'size' bytes
static int
devfile_trunc(struct Fd *fd, off_t newsize)
{
  80191b:	f3 0f 1e fb          	endbr32 
  80191f:	55                   	push   %ebp
  801920:	89 e5                	mov    %esp,%ebp
  801922:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.set_size.req_fileid = fd->fd_file.id;
  801925:	8b 45 08             	mov    0x8(%ebp),%eax
  801928:	8b 40 0c             	mov    0xc(%eax),%eax
  80192b:	a3 00 50 80 00       	mov    %eax,0x805000
	fsipcbuf.set_size.req_size = newsize;
  801930:	8b 45 0c             	mov    0xc(%ebp),%eax
  801933:	a3 04 50 80 00       	mov    %eax,0x805004
	return fsipc(FSREQ_SET_SIZE, NULL);
  801938:	ba 00 00 00 00       	mov    $0x0,%edx
  80193d:	b8 02 00 00 00       	mov    $0x2,%eax
  801942:	e8 87 ff ff ff       	call   8018ce <fsipc>
}
  801947:	c9                   	leave  
  801948:	c3                   	ret    

00801949 <devfile_flush>:
{
  801949:	f3 0f 1e fb          	endbr32 
  80194d:	55                   	push   %ebp
  80194e:	89 e5                	mov    %esp,%ebp
  801950:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.flush.req_fileid = fd->fd_file.id;
  801953:	8b 45 08             	mov    0x8(%ebp),%eax
  801956:	8b 40 0c             	mov    0xc(%eax),%eax
  801959:	a3 00 50 80 00       	mov    %eax,0x805000
	return fsipc(FSREQ_FLUSH, NULL);
  80195e:	ba 00 00 00 00       	mov    $0x0,%edx
  801963:	b8 06 00 00 00       	mov    $0x6,%eax
  801968:	e8 61 ff ff ff       	call   8018ce <fsipc>
}
  80196d:	c9                   	leave  
  80196e:	c3                   	ret    

0080196f <devfile_stat>:
{
  80196f:	f3 0f 1e fb          	endbr32 
  801973:	55                   	push   %ebp
  801974:	89 e5                	mov    %esp,%ebp
  801976:	53                   	push   %ebx
  801977:	83 ec 04             	sub    $0x4,%esp
  80197a:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	fsipcbuf.stat.req_fileid = fd->fd_file.id;
  80197d:	8b 45 08             	mov    0x8(%ebp),%eax
  801980:	8b 40 0c             	mov    0xc(%eax),%eax
  801983:	a3 00 50 80 00       	mov    %eax,0x805000
	if ((r = fsipc(FSREQ_STAT, NULL)) < 0)
  801988:	ba 00 00 00 00       	mov    $0x0,%edx
  80198d:	b8 05 00 00 00       	mov    $0x5,%eax
  801992:	e8 37 ff ff ff       	call   8018ce <fsipc>
  801997:	85 c0                	test   %eax,%eax
  801999:	78 2c                	js     8019c7 <devfile_stat+0x58>
	strcpy(st->st_name, fsipcbuf.statRet.ret_name);
  80199b:	83 ec 08             	sub    $0x8,%esp
  80199e:	68 00 50 80 00       	push   $0x805000
  8019a3:	53                   	push   %ebx
  8019a4:	e8 c2 ef ff ff       	call   80096b <strcpy>
	st->st_size = fsipcbuf.statRet.ret_size;
  8019a9:	a1 80 50 80 00       	mov    0x805080,%eax
  8019ae:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	st->st_isdir = fsipcbuf.statRet.ret_isdir;
  8019b4:	a1 84 50 80 00       	mov    0x805084,%eax
  8019b9:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
	return 0;
  8019bf:	83 c4 10             	add    $0x10,%esp
  8019c2:	b8 00 00 00 00       	mov    $0x0,%eax
}
  8019c7:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  8019ca:	c9                   	leave  
  8019cb:	c3                   	ret    

008019cc <devfile_write>:
{
  8019cc:	f3 0f 1e fb          	endbr32 
  8019d0:	55                   	push   %ebp
  8019d1:	89 e5                	mov    %esp,%ebp
  8019d3:	83 ec 0c             	sub    $0xc,%esp
  8019d6:	8b 45 10             	mov    0x10(%ebp),%eax
  8019d9:	3d f8 0f 00 00       	cmp    $0xff8,%eax
  8019de:	ba f8 0f 00 00       	mov    $0xff8,%edx
  8019e3:	0f 47 c2             	cmova  %edx,%eax
	fsipcbuf.write.req_fileid = fd->fd_file.id;
  8019e6:	8b 55 08             	mov    0x8(%ebp),%edx
  8019e9:	8b 52 0c             	mov    0xc(%edx),%edx
  8019ec:	89 15 00 50 80 00    	mov    %edx,0x805000
	fsipcbuf.write.req_n = n;
  8019f2:	a3 04 50 80 00       	mov    %eax,0x805004
	memmove(fsipcbuf.write.req_buf, buf, n);
  8019f7:	50                   	push   %eax
  8019f8:	ff 75 0c             	pushl  0xc(%ebp)
  8019fb:	68 08 50 80 00       	push   $0x805008
  801a00:	e8 1c f1 ff ff       	call   800b21 <memmove>
	return fsipc(FSREQ_WRITE, NULL);}
  801a05:	ba 00 00 00 00       	mov    $0x0,%edx
  801a0a:	b8 04 00 00 00       	mov    $0x4,%eax
  801a0f:	e8 ba fe ff ff       	call   8018ce <fsipc>
  801a14:	c9                   	leave  
  801a15:	c3                   	ret    

00801a16 <devfile_read>:
{
  801a16:	f3 0f 1e fb          	endbr32 
  801a1a:	55                   	push   %ebp
  801a1b:	89 e5                	mov    %esp,%ebp
  801a1d:	56                   	push   %esi
  801a1e:	53                   	push   %ebx
  801a1f:	8b 75 10             	mov    0x10(%ebp),%esi
	fsipcbuf.read.req_fileid = fd->fd_file.id;
  801a22:	8b 45 08             	mov    0x8(%ebp),%eax
  801a25:	8b 40 0c             	mov    0xc(%eax),%eax
  801a28:	a3 00 50 80 00       	mov    %eax,0x805000
	fsipcbuf.read.req_n = n;
  801a2d:	89 35 04 50 80 00    	mov    %esi,0x805004
	if ((r = fsipc(FSREQ_READ, NULL)) < 0)
  801a33:	ba 00 00 00 00       	mov    $0x0,%edx
  801a38:	b8 03 00 00 00       	mov    $0x3,%eax
  801a3d:	e8 8c fe ff ff       	call   8018ce <fsipc>
  801a42:	89 c3                	mov    %eax,%ebx
  801a44:	85 c0                	test   %eax,%eax
  801a46:	78 1f                	js     801a67 <devfile_read+0x51>
	assert(r <= n);
  801a48:	39 f0                	cmp    %esi,%eax
  801a4a:	77 24                	ja     801a70 <devfile_read+0x5a>
	assert(r <= PGSIZE);
  801a4c:	3d 00 10 00 00       	cmp    $0x1000,%eax
  801a51:	7f 33                	jg     801a86 <devfile_read+0x70>
	memmove(buf, fsipcbuf.readRet.ret_buf, r);
  801a53:	83 ec 04             	sub    $0x4,%esp
  801a56:	50                   	push   %eax
  801a57:	68 00 50 80 00       	push   $0x805000
  801a5c:	ff 75 0c             	pushl  0xc(%ebp)
  801a5f:	e8 bd f0 ff ff       	call   800b21 <memmove>
	return r;
  801a64:	83 c4 10             	add    $0x10,%esp
}
  801a67:	89 d8                	mov    %ebx,%eax
  801a69:	8d 65 f8             	lea    -0x8(%ebp),%esp
  801a6c:	5b                   	pop    %ebx
  801a6d:	5e                   	pop    %esi
  801a6e:	5d                   	pop    %ebp
  801a6f:	c3                   	ret    
	assert(r <= n);
  801a70:	68 88 2a 80 00       	push   $0x802a88
  801a75:	68 8f 2a 80 00       	push   $0x802a8f
  801a7a:	6a 7c                	push   $0x7c
  801a7c:	68 a4 2a 80 00       	push   $0x802aa4
  801a81:	e8 25 e8 ff ff       	call   8002ab <_panic>
	assert(r <= PGSIZE);
  801a86:	68 af 2a 80 00       	push   $0x802aaf
  801a8b:	68 8f 2a 80 00       	push   $0x802a8f
  801a90:	6a 7d                	push   $0x7d
  801a92:	68 a4 2a 80 00       	push   $0x802aa4
  801a97:	e8 0f e8 ff ff       	call   8002ab <_panic>

00801a9c <open>:
{
  801a9c:	f3 0f 1e fb          	endbr32 
  801aa0:	55                   	push   %ebp
  801aa1:	89 e5                	mov    %esp,%ebp
  801aa3:	56                   	push   %esi
  801aa4:	53                   	push   %ebx
  801aa5:	83 ec 1c             	sub    $0x1c,%esp
  801aa8:	8b 75 08             	mov    0x8(%ebp),%esi
	if (strlen(path) >= MAXPATHLEN)
  801aab:	56                   	push   %esi
  801aac:	e8 77 ee ff ff       	call   800928 <strlen>
  801ab1:	83 c4 10             	add    $0x10,%esp
  801ab4:	3d ff 03 00 00       	cmp    $0x3ff,%eax
  801ab9:	7f 6c                	jg     801b27 <open+0x8b>
	if ((r = fd_alloc(&fd)) < 0)
  801abb:	83 ec 0c             	sub    $0xc,%esp
  801abe:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801ac1:	50                   	push   %eax
  801ac2:	e8 67 f8 ff ff       	call   80132e <fd_alloc>
  801ac7:	89 c3                	mov    %eax,%ebx
  801ac9:	83 c4 10             	add    $0x10,%esp
  801acc:	85 c0                	test   %eax,%eax
  801ace:	78 3c                	js     801b0c <open+0x70>
	strcpy(fsipcbuf.open.req_path, path);
  801ad0:	83 ec 08             	sub    $0x8,%esp
  801ad3:	56                   	push   %esi
  801ad4:	68 00 50 80 00       	push   $0x805000
  801ad9:	e8 8d ee ff ff       	call   80096b <strcpy>
	fsipcbuf.open.req_omode = mode;
  801ade:	8b 45 0c             	mov    0xc(%ebp),%eax
  801ae1:	a3 00 54 80 00       	mov    %eax,0x805400
	if ((r = fsipc(FSREQ_OPEN, fd)) < 0) {
  801ae6:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801ae9:	b8 01 00 00 00       	mov    $0x1,%eax
  801aee:	e8 db fd ff ff       	call   8018ce <fsipc>
  801af3:	89 c3                	mov    %eax,%ebx
  801af5:	83 c4 10             	add    $0x10,%esp
  801af8:	85 c0                	test   %eax,%eax
  801afa:	78 19                	js     801b15 <open+0x79>
	return fd2num(fd);
  801afc:	83 ec 0c             	sub    $0xc,%esp
  801aff:	ff 75 f4             	pushl  -0xc(%ebp)
  801b02:	e8 f8 f7 ff ff       	call   8012ff <fd2num>
  801b07:	89 c3                	mov    %eax,%ebx
  801b09:	83 c4 10             	add    $0x10,%esp
}
  801b0c:	89 d8                	mov    %ebx,%eax
  801b0e:	8d 65 f8             	lea    -0x8(%ebp),%esp
  801b11:	5b                   	pop    %ebx
  801b12:	5e                   	pop    %esi
  801b13:	5d                   	pop    %ebp
  801b14:	c3                   	ret    
		fd_close(fd, 0);
  801b15:	83 ec 08             	sub    $0x8,%esp
  801b18:	6a 00                	push   $0x0
  801b1a:	ff 75 f4             	pushl  -0xc(%ebp)
  801b1d:	e8 10 f9 ff ff       	call   801432 <fd_close>
		return r;
  801b22:	83 c4 10             	add    $0x10,%esp
  801b25:	eb e5                	jmp    801b0c <open+0x70>
		return -E_BAD_PATH;
  801b27:	bb f4 ff ff ff       	mov    $0xfffffff4,%ebx
  801b2c:	eb de                	jmp    801b0c <open+0x70>

00801b2e <sync>:


// Synchronize disk with buffer cache
int
sync(void)
{
  801b2e:	f3 0f 1e fb          	endbr32 
  801b32:	55                   	push   %ebp
  801b33:	89 e5                	mov    %esp,%ebp
  801b35:	83 ec 08             	sub    $0x8,%esp
	// Ask the file server to update the disk
	// by writing any dirty blocks in the buffer cache.

	return fsipc(FSREQ_SYNC, NULL);
  801b38:	ba 00 00 00 00       	mov    $0x0,%edx
  801b3d:	b8 08 00 00 00       	mov    $0x8,%eax
  801b42:	e8 87 fd ff ff       	call   8018ce <fsipc>
}
  801b47:	c9                   	leave  
  801b48:	c3                   	ret    

00801b49 <devpipe_stat>:
	return i;
}

static int
devpipe_stat(struct Fd *fd, struct Stat *stat)
{
  801b49:	f3 0f 1e fb          	endbr32 
  801b4d:	55                   	push   %ebp
  801b4e:	89 e5                	mov    %esp,%ebp
  801b50:	56                   	push   %esi
  801b51:	53                   	push   %ebx
  801b52:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	struct Pipe *p = (struct Pipe*) fd2data(fd);
  801b55:	83 ec 0c             	sub    $0xc,%esp
  801b58:	ff 75 08             	pushl  0x8(%ebp)
  801b5b:	e8 b3 f7 ff ff       	call   801313 <fd2data>
  801b60:	89 c6                	mov    %eax,%esi
	strcpy(stat->st_name, "<pipe>");
  801b62:	83 c4 08             	add    $0x8,%esp
  801b65:	68 bb 2a 80 00       	push   $0x802abb
  801b6a:	53                   	push   %ebx
  801b6b:	e8 fb ed ff ff       	call   80096b <strcpy>
	stat->st_size = p->p_wpos - p->p_rpos;
  801b70:	8b 46 04             	mov    0x4(%esi),%eax
  801b73:	2b 06                	sub    (%esi),%eax
  801b75:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	stat->st_isdir = 0;
  801b7b:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  801b82:	00 00 00 
	stat->st_dev = &devpipe;
  801b85:	c7 83 88 00 00 00 20 	movl   $0x803020,0x88(%ebx)
  801b8c:	30 80 00 
	return 0;
}
  801b8f:	b8 00 00 00 00       	mov    $0x0,%eax
  801b94:	8d 65 f8             	lea    -0x8(%ebp),%esp
  801b97:	5b                   	pop    %ebx
  801b98:	5e                   	pop    %esi
  801b99:	5d                   	pop    %ebp
  801b9a:	c3                   	ret    

00801b9b <devpipe_close>:

static int
devpipe_close(struct Fd *fd)
{
  801b9b:	f3 0f 1e fb          	endbr32 
  801b9f:	55                   	push   %ebp
  801ba0:	89 e5                	mov    %esp,%ebp
  801ba2:	53                   	push   %ebx
  801ba3:	83 ec 0c             	sub    $0xc,%esp
  801ba6:	8b 5d 08             	mov    0x8(%ebp),%ebx
	(void) sys_page_unmap(0, fd);
  801ba9:	53                   	push   %ebx
  801baa:	6a 00                	push   $0x0
  801bac:	e8 89 f2 ff ff       	call   800e3a <sys_page_unmap>
	return sys_page_unmap(0, fd2data(fd));
  801bb1:	89 1c 24             	mov    %ebx,(%esp)
  801bb4:	e8 5a f7 ff ff       	call   801313 <fd2data>
  801bb9:	83 c4 08             	add    $0x8,%esp
  801bbc:	50                   	push   %eax
  801bbd:	6a 00                	push   $0x0
  801bbf:	e8 76 f2 ff ff       	call   800e3a <sys_page_unmap>
}
  801bc4:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  801bc7:	c9                   	leave  
  801bc8:	c3                   	ret    

00801bc9 <_pipeisclosed>:
{
  801bc9:	55                   	push   %ebp
  801bca:	89 e5                	mov    %esp,%ebp
  801bcc:	57                   	push   %edi
  801bcd:	56                   	push   %esi
  801bce:	53                   	push   %ebx
  801bcf:	83 ec 1c             	sub    $0x1c,%esp
  801bd2:	89 c7                	mov    %eax,%edi
  801bd4:	89 d6                	mov    %edx,%esi
		n = thisenv->env_runs;
  801bd6:	a1 04 40 80 00       	mov    0x804004,%eax
  801bdb:	8b 58 58             	mov    0x58(%eax),%ebx
		ret = pageref(fd) == pageref(p);
  801bde:	83 ec 0c             	sub    $0xc,%esp
  801be1:	57                   	push   %edi
  801be2:	e8 14 06 00 00       	call   8021fb <pageref>
  801be7:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  801bea:	89 34 24             	mov    %esi,(%esp)
  801bed:	e8 09 06 00 00       	call   8021fb <pageref>
		nn = thisenv->env_runs;
  801bf2:	8b 15 04 40 80 00    	mov    0x804004,%edx
  801bf8:	8b 4a 58             	mov    0x58(%edx),%ecx
		if (n == nn)
  801bfb:	83 c4 10             	add    $0x10,%esp
  801bfe:	39 cb                	cmp    %ecx,%ebx
  801c00:	74 1b                	je     801c1d <_pipeisclosed+0x54>
		if (n != nn && ret == 1)
  801c02:	39 45 e4             	cmp    %eax,-0x1c(%ebp)
  801c05:	75 cf                	jne    801bd6 <_pipeisclosed+0xd>
			cprintf("pipe race avoided\n", n, thisenv->env_runs, ret);
  801c07:	8b 42 58             	mov    0x58(%edx),%eax
  801c0a:	6a 01                	push   $0x1
  801c0c:	50                   	push   %eax
  801c0d:	53                   	push   %ebx
  801c0e:	68 c2 2a 80 00       	push   $0x802ac2
  801c13:	e8 7a e7 ff ff       	call   800392 <cprintf>
  801c18:	83 c4 10             	add    $0x10,%esp
  801c1b:	eb b9                	jmp    801bd6 <_pipeisclosed+0xd>
		ret = pageref(fd) == pageref(p);
  801c1d:	39 45 e4             	cmp    %eax,-0x1c(%ebp)
  801c20:	0f 94 c0             	sete   %al
  801c23:	0f b6 c0             	movzbl %al,%eax
}
  801c26:	8d 65 f4             	lea    -0xc(%ebp),%esp
  801c29:	5b                   	pop    %ebx
  801c2a:	5e                   	pop    %esi
  801c2b:	5f                   	pop    %edi
  801c2c:	5d                   	pop    %ebp
  801c2d:	c3                   	ret    

00801c2e <devpipe_write>:
{
  801c2e:	f3 0f 1e fb          	endbr32 
  801c32:	55                   	push   %ebp
  801c33:	89 e5                	mov    %esp,%ebp
  801c35:	57                   	push   %edi
  801c36:	56                   	push   %esi
  801c37:	53                   	push   %ebx
  801c38:	83 ec 28             	sub    $0x28,%esp
  801c3b:	8b 75 08             	mov    0x8(%ebp),%esi
	p = (struct Pipe*) fd2data(fd);
  801c3e:	56                   	push   %esi
  801c3f:	e8 cf f6 ff ff       	call   801313 <fd2data>
  801c44:	89 c3                	mov    %eax,%ebx
	for (i = 0; i < n; i++) {
  801c46:	83 c4 10             	add    $0x10,%esp
  801c49:	bf 00 00 00 00       	mov    $0x0,%edi
  801c4e:	3b 7d 10             	cmp    0x10(%ebp),%edi
  801c51:	74 4f                	je     801ca2 <devpipe_write+0x74>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  801c53:	8b 43 04             	mov    0x4(%ebx),%eax
  801c56:	8b 0b                	mov    (%ebx),%ecx
  801c58:	8d 51 20             	lea    0x20(%ecx),%edx
  801c5b:	39 d0                	cmp    %edx,%eax
  801c5d:	72 14                	jb     801c73 <devpipe_write+0x45>
			if (_pipeisclosed(fd, p))
  801c5f:	89 da                	mov    %ebx,%edx
  801c61:	89 f0                	mov    %esi,%eax
  801c63:	e8 61 ff ff ff       	call   801bc9 <_pipeisclosed>
  801c68:	85 c0                	test   %eax,%eax
  801c6a:	75 3b                	jne    801ca7 <devpipe_write+0x79>
			sys_yield();
  801c6c:	e8 19 f1 ff ff       	call   800d8a <sys_yield>
  801c71:	eb e0                	jmp    801c53 <devpipe_write+0x25>
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
  801c73:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801c76:	0f b6 0c 39          	movzbl (%ecx,%edi,1),%ecx
  801c7a:	88 4d e7             	mov    %cl,-0x19(%ebp)
  801c7d:	89 c2                	mov    %eax,%edx
  801c7f:	c1 fa 1f             	sar    $0x1f,%edx
  801c82:	89 d1                	mov    %edx,%ecx
  801c84:	c1 e9 1b             	shr    $0x1b,%ecx
  801c87:	8d 14 08             	lea    (%eax,%ecx,1),%edx
  801c8a:	83 e2 1f             	and    $0x1f,%edx
  801c8d:	29 ca                	sub    %ecx,%edx
  801c8f:	0f b6 4d e7          	movzbl -0x19(%ebp),%ecx
  801c93:	88 4c 13 08          	mov    %cl,0x8(%ebx,%edx,1)
		p->p_wpos++;
  801c97:	83 c0 01             	add    $0x1,%eax
  801c9a:	89 43 04             	mov    %eax,0x4(%ebx)
	for (i = 0; i < n; i++) {
  801c9d:	83 c7 01             	add    $0x1,%edi
  801ca0:	eb ac                	jmp    801c4e <devpipe_write+0x20>
	return i;
  801ca2:	8b 45 10             	mov    0x10(%ebp),%eax
  801ca5:	eb 05                	jmp    801cac <devpipe_write+0x7e>
				return 0;
  801ca7:	b8 00 00 00 00       	mov    $0x0,%eax
}
  801cac:	8d 65 f4             	lea    -0xc(%ebp),%esp
  801caf:	5b                   	pop    %ebx
  801cb0:	5e                   	pop    %esi
  801cb1:	5f                   	pop    %edi
  801cb2:	5d                   	pop    %ebp
  801cb3:	c3                   	ret    

00801cb4 <devpipe_read>:
{
  801cb4:	f3 0f 1e fb          	endbr32 
  801cb8:	55                   	push   %ebp
  801cb9:	89 e5                	mov    %esp,%ebp
  801cbb:	57                   	push   %edi
  801cbc:	56                   	push   %esi
  801cbd:	53                   	push   %ebx
  801cbe:	83 ec 18             	sub    $0x18,%esp
  801cc1:	8b 7d 08             	mov    0x8(%ebp),%edi
	p = (struct Pipe*)fd2data(fd);
  801cc4:	57                   	push   %edi
  801cc5:	e8 49 f6 ff ff       	call   801313 <fd2data>
  801cca:	89 c3                	mov    %eax,%ebx
	for (i = 0; i < n; i++) {
  801ccc:	83 c4 10             	add    $0x10,%esp
  801ccf:	be 00 00 00 00       	mov    $0x0,%esi
  801cd4:	3b 75 10             	cmp    0x10(%ebp),%esi
  801cd7:	75 14                	jne    801ced <devpipe_read+0x39>
	return i;
  801cd9:	8b 45 10             	mov    0x10(%ebp),%eax
  801cdc:	eb 02                	jmp    801ce0 <devpipe_read+0x2c>
				return i;
  801cde:	89 f0                	mov    %esi,%eax
}
  801ce0:	8d 65 f4             	lea    -0xc(%ebp),%esp
  801ce3:	5b                   	pop    %ebx
  801ce4:	5e                   	pop    %esi
  801ce5:	5f                   	pop    %edi
  801ce6:	5d                   	pop    %ebp
  801ce7:	c3                   	ret    
			sys_yield();
  801ce8:	e8 9d f0 ff ff       	call   800d8a <sys_yield>
		while (p->p_rpos == p->p_wpos) {
  801ced:	8b 03                	mov    (%ebx),%eax
  801cef:	3b 43 04             	cmp    0x4(%ebx),%eax
  801cf2:	75 18                	jne    801d0c <devpipe_read+0x58>
			if (i > 0)
  801cf4:	85 f6                	test   %esi,%esi
  801cf6:	75 e6                	jne    801cde <devpipe_read+0x2a>
			if (_pipeisclosed(fd, p))
  801cf8:	89 da                	mov    %ebx,%edx
  801cfa:	89 f8                	mov    %edi,%eax
  801cfc:	e8 c8 fe ff ff       	call   801bc9 <_pipeisclosed>
  801d01:	85 c0                	test   %eax,%eax
  801d03:	74 e3                	je     801ce8 <devpipe_read+0x34>
				return 0;
  801d05:	b8 00 00 00 00       	mov    $0x0,%eax
  801d0a:	eb d4                	jmp    801ce0 <devpipe_read+0x2c>
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
  801d0c:	99                   	cltd   
  801d0d:	c1 ea 1b             	shr    $0x1b,%edx
  801d10:	01 d0                	add    %edx,%eax
  801d12:	83 e0 1f             	and    $0x1f,%eax
  801d15:	29 d0                	sub    %edx,%eax
  801d17:	0f b6 44 03 08       	movzbl 0x8(%ebx,%eax,1),%eax
  801d1c:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801d1f:	88 04 31             	mov    %al,(%ecx,%esi,1)
		p->p_rpos++;
  801d22:	83 03 01             	addl   $0x1,(%ebx)
	for (i = 0; i < n; i++) {
  801d25:	83 c6 01             	add    $0x1,%esi
  801d28:	eb aa                	jmp    801cd4 <devpipe_read+0x20>

00801d2a <pipe>:
{
  801d2a:	f3 0f 1e fb          	endbr32 
  801d2e:	55                   	push   %ebp
  801d2f:	89 e5                	mov    %esp,%ebp
  801d31:	56                   	push   %esi
  801d32:	53                   	push   %ebx
  801d33:	83 ec 1c             	sub    $0x1c,%esp
	if ((r = fd_alloc(&fd0)) < 0
  801d36:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801d39:	50                   	push   %eax
  801d3a:	e8 ef f5 ff ff       	call   80132e <fd_alloc>
  801d3f:	89 c3                	mov    %eax,%ebx
  801d41:	83 c4 10             	add    $0x10,%esp
  801d44:	85 c0                	test   %eax,%eax
  801d46:	0f 88 23 01 00 00    	js     801e6f <pipe+0x145>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  801d4c:	83 ec 04             	sub    $0x4,%esp
  801d4f:	68 07 04 00 00       	push   $0x407
  801d54:	ff 75 f4             	pushl  -0xc(%ebp)
  801d57:	6a 00                	push   $0x0
  801d59:	e8 4f f0 ff ff       	call   800dad <sys_page_alloc>
  801d5e:	89 c3                	mov    %eax,%ebx
  801d60:	83 c4 10             	add    $0x10,%esp
  801d63:	85 c0                	test   %eax,%eax
  801d65:	0f 88 04 01 00 00    	js     801e6f <pipe+0x145>
	if ((r = fd_alloc(&fd1)) < 0
  801d6b:	83 ec 0c             	sub    $0xc,%esp
  801d6e:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801d71:	50                   	push   %eax
  801d72:	e8 b7 f5 ff ff       	call   80132e <fd_alloc>
  801d77:	89 c3                	mov    %eax,%ebx
  801d79:	83 c4 10             	add    $0x10,%esp
  801d7c:	85 c0                	test   %eax,%eax
  801d7e:	0f 88 db 00 00 00    	js     801e5f <pipe+0x135>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  801d84:	83 ec 04             	sub    $0x4,%esp
  801d87:	68 07 04 00 00       	push   $0x407
  801d8c:	ff 75 f0             	pushl  -0x10(%ebp)
  801d8f:	6a 00                	push   $0x0
  801d91:	e8 17 f0 ff ff       	call   800dad <sys_page_alloc>
  801d96:	89 c3                	mov    %eax,%ebx
  801d98:	83 c4 10             	add    $0x10,%esp
  801d9b:	85 c0                	test   %eax,%eax
  801d9d:	0f 88 bc 00 00 00    	js     801e5f <pipe+0x135>
	va = fd2data(fd0);
  801da3:	83 ec 0c             	sub    $0xc,%esp
  801da6:	ff 75 f4             	pushl  -0xc(%ebp)
  801da9:	e8 65 f5 ff ff       	call   801313 <fd2data>
  801dae:	89 c6                	mov    %eax,%esi
	if ((r = sys_page_alloc(0, va, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  801db0:	83 c4 0c             	add    $0xc,%esp
  801db3:	68 07 04 00 00       	push   $0x407
  801db8:	50                   	push   %eax
  801db9:	6a 00                	push   $0x0
  801dbb:	e8 ed ef ff ff       	call   800dad <sys_page_alloc>
  801dc0:	89 c3                	mov    %eax,%ebx
  801dc2:	83 c4 10             	add    $0x10,%esp
  801dc5:	85 c0                	test   %eax,%eax
  801dc7:	0f 88 82 00 00 00    	js     801e4f <pipe+0x125>
	if ((r = sys_page_map(0, va, 0, fd2data(fd1), PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  801dcd:	83 ec 0c             	sub    $0xc,%esp
  801dd0:	ff 75 f0             	pushl  -0x10(%ebp)
  801dd3:	e8 3b f5 ff ff       	call   801313 <fd2data>
  801dd8:	c7 04 24 07 04 00 00 	movl   $0x407,(%esp)
  801ddf:	50                   	push   %eax
  801de0:	6a 00                	push   $0x0
  801de2:	56                   	push   %esi
  801de3:	6a 00                	push   $0x0
  801de5:	e8 0a f0 ff ff       	call   800df4 <sys_page_map>
  801dea:	89 c3                	mov    %eax,%ebx
  801dec:	83 c4 20             	add    $0x20,%esp
  801def:	85 c0                	test   %eax,%eax
  801df1:	78 4e                	js     801e41 <pipe+0x117>
	fd0->fd_dev_id = devpipe.dev_id;
  801df3:	a1 20 30 80 00       	mov    0x803020,%eax
  801df8:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801dfb:	89 02                	mov    %eax,(%edx)
	fd0->fd_omode = O_RDONLY;
  801dfd:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801e00:	c7 42 08 00 00 00 00 	movl   $0x0,0x8(%edx)
	fd1->fd_dev_id = devpipe.dev_id;
  801e07:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801e0a:	89 02                	mov    %eax,(%edx)
	fd1->fd_omode = O_WRONLY;
  801e0c:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801e0f:	c7 40 08 01 00 00 00 	movl   $0x1,0x8(%eax)
	pfd[0] = fd2num(fd0);
  801e16:	83 ec 0c             	sub    $0xc,%esp
  801e19:	ff 75 f4             	pushl  -0xc(%ebp)
  801e1c:	e8 de f4 ff ff       	call   8012ff <fd2num>
  801e21:	8b 4d 08             	mov    0x8(%ebp),%ecx
  801e24:	89 01                	mov    %eax,(%ecx)
	pfd[1] = fd2num(fd1);
  801e26:	83 c4 04             	add    $0x4,%esp
  801e29:	ff 75 f0             	pushl  -0x10(%ebp)
  801e2c:	e8 ce f4 ff ff       	call   8012ff <fd2num>
  801e31:	8b 4d 08             	mov    0x8(%ebp),%ecx
  801e34:	89 41 04             	mov    %eax,0x4(%ecx)
	return 0;
  801e37:	83 c4 10             	add    $0x10,%esp
  801e3a:	bb 00 00 00 00       	mov    $0x0,%ebx
  801e3f:	eb 2e                	jmp    801e6f <pipe+0x145>
	sys_page_unmap(0, va);
  801e41:	83 ec 08             	sub    $0x8,%esp
  801e44:	56                   	push   %esi
  801e45:	6a 00                	push   $0x0
  801e47:	e8 ee ef ff ff       	call   800e3a <sys_page_unmap>
  801e4c:	83 c4 10             	add    $0x10,%esp
	sys_page_unmap(0, fd1);
  801e4f:	83 ec 08             	sub    $0x8,%esp
  801e52:	ff 75 f0             	pushl  -0x10(%ebp)
  801e55:	6a 00                	push   $0x0
  801e57:	e8 de ef ff ff       	call   800e3a <sys_page_unmap>
  801e5c:	83 c4 10             	add    $0x10,%esp
	sys_page_unmap(0, fd0);
  801e5f:	83 ec 08             	sub    $0x8,%esp
  801e62:	ff 75 f4             	pushl  -0xc(%ebp)
  801e65:	6a 00                	push   $0x0
  801e67:	e8 ce ef ff ff       	call   800e3a <sys_page_unmap>
  801e6c:	83 c4 10             	add    $0x10,%esp
}
  801e6f:	89 d8                	mov    %ebx,%eax
  801e71:	8d 65 f8             	lea    -0x8(%ebp),%esp
  801e74:	5b                   	pop    %ebx
  801e75:	5e                   	pop    %esi
  801e76:	5d                   	pop    %ebp
  801e77:	c3                   	ret    

00801e78 <pipeisclosed>:
{
  801e78:	f3 0f 1e fb          	endbr32 
  801e7c:	55                   	push   %ebp
  801e7d:	89 e5                	mov    %esp,%ebp
  801e7f:	83 ec 20             	sub    $0x20,%esp
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  801e82:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801e85:	50                   	push   %eax
  801e86:	ff 75 08             	pushl  0x8(%ebp)
  801e89:	e8 f6 f4 ff ff       	call   801384 <fd_lookup>
  801e8e:	83 c4 10             	add    $0x10,%esp
  801e91:	85 c0                	test   %eax,%eax
  801e93:	78 18                	js     801ead <pipeisclosed+0x35>
	p = (struct Pipe*) fd2data(fd);
  801e95:	83 ec 0c             	sub    $0xc,%esp
  801e98:	ff 75 f4             	pushl  -0xc(%ebp)
  801e9b:	e8 73 f4 ff ff       	call   801313 <fd2data>
  801ea0:	89 c2                	mov    %eax,%edx
	return _pipeisclosed(fd, p);
  801ea2:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801ea5:	e8 1f fd ff ff       	call   801bc9 <_pipeisclosed>
  801eaa:	83 c4 10             	add    $0x10,%esp
}
  801ead:	c9                   	leave  
  801eae:	c3                   	ret    

00801eaf <devcons_close>:
	return tot;
}

static int
devcons_close(struct Fd *fd)
{
  801eaf:	f3 0f 1e fb          	endbr32 
	USED(fd);

	return 0;
}
  801eb3:	b8 00 00 00 00       	mov    $0x0,%eax
  801eb8:	c3                   	ret    

00801eb9 <devcons_stat>:

static int
devcons_stat(struct Fd *fd, struct Stat *stat)
{
  801eb9:	f3 0f 1e fb          	endbr32 
  801ebd:	55                   	push   %ebp
  801ebe:	89 e5                	mov    %esp,%ebp
  801ec0:	83 ec 10             	sub    $0x10,%esp
	strcpy(stat->st_name, "<cons>");
  801ec3:	68 d5 2a 80 00       	push   $0x802ad5
  801ec8:	ff 75 0c             	pushl  0xc(%ebp)
  801ecb:	e8 9b ea ff ff       	call   80096b <strcpy>
	return 0;
}
  801ed0:	b8 00 00 00 00       	mov    $0x0,%eax
  801ed5:	c9                   	leave  
  801ed6:	c3                   	ret    

00801ed7 <devcons_write>:
{
  801ed7:	f3 0f 1e fb          	endbr32 
  801edb:	55                   	push   %ebp
  801edc:	89 e5                	mov    %esp,%ebp
  801ede:	57                   	push   %edi
  801edf:	56                   	push   %esi
  801ee0:	53                   	push   %ebx
  801ee1:	81 ec 8c 00 00 00    	sub    $0x8c,%esp
	for (tot = 0; tot < n; tot += m) {
  801ee7:	be 00 00 00 00       	mov    $0x0,%esi
		memmove(buf, (char*)vbuf + tot, m);
  801eec:	8d bd 68 ff ff ff    	lea    -0x98(%ebp),%edi
	for (tot = 0; tot < n; tot += m) {
  801ef2:	3b 75 10             	cmp    0x10(%ebp),%esi
  801ef5:	73 31                	jae    801f28 <devcons_write+0x51>
		m = n - tot;
  801ef7:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801efa:	29 f3                	sub    %esi,%ebx
  801efc:	83 fb 7f             	cmp    $0x7f,%ebx
  801eff:	b8 7f 00 00 00       	mov    $0x7f,%eax
  801f04:	0f 47 d8             	cmova  %eax,%ebx
		memmove(buf, (char*)vbuf + tot, m);
  801f07:	83 ec 04             	sub    $0x4,%esp
  801f0a:	53                   	push   %ebx
  801f0b:	89 f0                	mov    %esi,%eax
  801f0d:	03 45 0c             	add    0xc(%ebp),%eax
  801f10:	50                   	push   %eax
  801f11:	57                   	push   %edi
  801f12:	e8 0a ec ff ff       	call   800b21 <memmove>
		sys_cputs(buf, m);
  801f17:	83 c4 08             	add    $0x8,%esp
  801f1a:	53                   	push   %ebx
  801f1b:	57                   	push   %edi
  801f1c:	e8 bc ed ff ff       	call   800cdd <sys_cputs>
	for (tot = 0; tot < n; tot += m) {
  801f21:	01 de                	add    %ebx,%esi
  801f23:	83 c4 10             	add    $0x10,%esp
  801f26:	eb ca                	jmp    801ef2 <devcons_write+0x1b>
}
  801f28:	89 f0                	mov    %esi,%eax
  801f2a:	8d 65 f4             	lea    -0xc(%ebp),%esp
  801f2d:	5b                   	pop    %ebx
  801f2e:	5e                   	pop    %esi
  801f2f:	5f                   	pop    %edi
  801f30:	5d                   	pop    %ebp
  801f31:	c3                   	ret    

00801f32 <devcons_read>:
{
  801f32:	f3 0f 1e fb          	endbr32 
  801f36:	55                   	push   %ebp
  801f37:	89 e5                	mov    %esp,%ebp
  801f39:	83 ec 08             	sub    $0x8,%esp
  801f3c:	b8 00 00 00 00       	mov    $0x0,%eax
	if (n == 0)
  801f41:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  801f45:	74 21                	je     801f68 <devcons_read+0x36>
	while ((c = sys_cgetc()) == 0)
  801f47:	e8 b3 ed ff ff       	call   800cff <sys_cgetc>
  801f4c:	85 c0                	test   %eax,%eax
  801f4e:	75 07                	jne    801f57 <devcons_read+0x25>
		sys_yield();
  801f50:	e8 35 ee ff ff       	call   800d8a <sys_yield>
  801f55:	eb f0                	jmp    801f47 <devcons_read+0x15>
	if (c < 0)
  801f57:	78 0f                	js     801f68 <devcons_read+0x36>
	if (c == 0x04)	// ctl-d is eof
  801f59:	83 f8 04             	cmp    $0x4,%eax
  801f5c:	74 0c                	je     801f6a <devcons_read+0x38>
	*(char*)vbuf = c;
  801f5e:	8b 55 0c             	mov    0xc(%ebp),%edx
  801f61:	88 02                	mov    %al,(%edx)
	return 1;
  801f63:	b8 01 00 00 00       	mov    $0x1,%eax
}
  801f68:	c9                   	leave  
  801f69:	c3                   	ret    
		return 0;
  801f6a:	b8 00 00 00 00       	mov    $0x0,%eax
  801f6f:	eb f7                	jmp    801f68 <devcons_read+0x36>

00801f71 <cputchar>:
{
  801f71:	f3 0f 1e fb          	endbr32 
  801f75:	55                   	push   %ebp
  801f76:	89 e5                	mov    %esp,%ebp
  801f78:	83 ec 20             	sub    $0x20,%esp
	char c = ch;
  801f7b:	8b 45 08             	mov    0x8(%ebp),%eax
  801f7e:	88 45 f7             	mov    %al,-0x9(%ebp)
	sys_cputs(&c, 1);
  801f81:	6a 01                	push   $0x1
  801f83:	8d 45 f7             	lea    -0x9(%ebp),%eax
  801f86:	50                   	push   %eax
  801f87:	e8 51 ed ff ff       	call   800cdd <sys_cputs>
}
  801f8c:	83 c4 10             	add    $0x10,%esp
  801f8f:	c9                   	leave  
  801f90:	c3                   	ret    

00801f91 <getchar>:
{
  801f91:	f3 0f 1e fb          	endbr32 
  801f95:	55                   	push   %ebp
  801f96:	89 e5                	mov    %esp,%ebp
  801f98:	83 ec 1c             	sub    $0x1c,%esp
	r = read(0, &c, 1);
  801f9b:	6a 01                	push   $0x1
  801f9d:	8d 45 f7             	lea    -0x9(%ebp),%eax
  801fa0:	50                   	push   %eax
  801fa1:	6a 00                	push   $0x0
  801fa3:	e8 5f f6 ff ff       	call   801607 <read>
	if (r < 0)
  801fa8:	83 c4 10             	add    $0x10,%esp
  801fab:	85 c0                	test   %eax,%eax
  801fad:	78 06                	js     801fb5 <getchar+0x24>
	if (r < 1)
  801faf:	74 06                	je     801fb7 <getchar+0x26>
	return c;
  801fb1:	0f b6 45 f7          	movzbl -0x9(%ebp),%eax
}
  801fb5:	c9                   	leave  
  801fb6:	c3                   	ret    
		return -E_EOF;
  801fb7:	b8 f8 ff ff ff       	mov    $0xfffffff8,%eax
  801fbc:	eb f7                	jmp    801fb5 <getchar+0x24>

00801fbe <iscons>:
{
  801fbe:	f3 0f 1e fb          	endbr32 
  801fc2:	55                   	push   %ebp
  801fc3:	89 e5                	mov    %esp,%ebp
  801fc5:	83 ec 20             	sub    $0x20,%esp
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  801fc8:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801fcb:	50                   	push   %eax
  801fcc:	ff 75 08             	pushl  0x8(%ebp)
  801fcf:	e8 b0 f3 ff ff       	call   801384 <fd_lookup>
  801fd4:	83 c4 10             	add    $0x10,%esp
  801fd7:	85 c0                	test   %eax,%eax
  801fd9:	78 11                	js     801fec <iscons+0x2e>
	return fd->fd_dev_id == devcons.dev_id;
  801fdb:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801fde:	8b 15 3c 30 80 00    	mov    0x80303c,%edx
  801fe4:	39 10                	cmp    %edx,(%eax)
  801fe6:	0f 94 c0             	sete   %al
  801fe9:	0f b6 c0             	movzbl %al,%eax
}
  801fec:	c9                   	leave  
  801fed:	c3                   	ret    

00801fee <opencons>:
{
  801fee:	f3 0f 1e fb          	endbr32 
  801ff2:	55                   	push   %ebp
  801ff3:	89 e5                	mov    %esp,%ebp
  801ff5:	83 ec 24             	sub    $0x24,%esp
	if ((r = fd_alloc(&fd)) < 0)
  801ff8:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801ffb:	50                   	push   %eax
  801ffc:	e8 2d f3 ff ff       	call   80132e <fd_alloc>
  802001:	83 c4 10             	add    $0x10,%esp
  802004:	85 c0                	test   %eax,%eax
  802006:	78 3a                	js     802042 <opencons+0x54>
	if ((r = sys_page_alloc(0, fd, PTE_P|PTE_U|PTE_W|PTE_SHARE)) < 0)
  802008:	83 ec 04             	sub    $0x4,%esp
  80200b:	68 07 04 00 00       	push   $0x407
  802010:	ff 75 f4             	pushl  -0xc(%ebp)
  802013:	6a 00                	push   $0x0
  802015:	e8 93 ed ff ff       	call   800dad <sys_page_alloc>
  80201a:	83 c4 10             	add    $0x10,%esp
  80201d:	85 c0                	test   %eax,%eax
  80201f:	78 21                	js     802042 <opencons+0x54>
	fd->fd_dev_id = devcons.dev_id;
  802021:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802024:	8b 15 3c 30 80 00    	mov    0x80303c,%edx
  80202a:	89 10                	mov    %edx,(%eax)
	fd->fd_omode = O_RDWR;
  80202c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80202f:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	return fd2num(fd);
  802036:	83 ec 0c             	sub    $0xc,%esp
  802039:	50                   	push   %eax
  80203a:	e8 c0 f2 ff ff       	call   8012ff <fd2num>
  80203f:	83 c4 10             	add    $0x10,%esp
}
  802042:	c9                   	leave  
  802043:	c3                   	ret    

00802044 <set_pgfault_handler>:
// at UXSTACKTOP), and tell the kernel to call the assembly-language
// _pgfault_upcall routine when a page fault occurs.
//
void
set_pgfault_handler(void (*handler)(struct UTrapframe *utf))
{
  802044:	f3 0f 1e fb          	endbr32 
  802048:	55                   	push   %ebp
  802049:	89 e5                	mov    %esp,%ebp
  80204b:	83 ec 08             	sub    $0x8,%esp
	int r;

	if (_pgfault_handler == 0) {
  80204e:	83 3d 00 60 80 00 00 	cmpl   $0x0,0x806000
  802055:	74 27                	je     80207e <set_pgfault_handler+0x3a>
		if(sys_page_alloc(0,(void *)UXSTACKTOP-PGSIZE,PTE_W|PTE_U|PTE_P)<0)
			panic("set_pgfault_handler:sys_page_alloc failed");
	}

	// Save handler pointer for assembly to call.
	_pgfault_handler = handler;
  802057:	8b 45 08             	mov    0x8(%ebp),%eax
  80205a:	a3 00 60 80 00       	mov    %eax,0x806000
	if (sys_env_set_pgfault_upcall(thisenv->env_id,_pgfault_upcall)<0)	
  80205f:	a1 04 40 80 00       	mov    0x804004,%eax
  802064:	8b 40 48             	mov    0x48(%eax),%eax
  802067:	83 ec 08             	sub    $0x8,%esp
  80206a:	68 be 20 80 00       	push   $0x8020be
  80206f:	50                   	push   %eax
  802070:	e8 97 ee ff ff       	call   800f0c <sys_env_set_pgfault_upcall>
  802075:	83 c4 10             	add    $0x10,%esp
  802078:	85 c0                	test   %eax,%eax
  80207a:	78 2e                	js     8020aa <set_pgfault_handler+0x66>
        panic("set_pgfault_handler:sys_env_set_pgfault_upcall failed");
}
  80207c:	c9                   	leave  
  80207d:	c3                   	ret    
		if(sys_page_alloc(0,(void *)UXSTACKTOP-PGSIZE,PTE_W|PTE_U|PTE_P)<0)
  80207e:	83 ec 04             	sub    $0x4,%esp
  802081:	6a 07                	push   $0x7
  802083:	68 00 f0 bf ee       	push   $0xeebff000
  802088:	6a 00                	push   $0x0
  80208a:	e8 1e ed ff ff       	call   800dad <sys_page_alloc>
  80208f:	83 c4 10             	add    $0x10,%esp
  802092:	85 c0                	test   %eax,%eax
  802094:	79 c1                	jns    802057 <set_pgfault_handler+0x13>
			panic("set_pgfault_handler:sys_page_alloc failed");
  802096:	83 ec 04             	sub    $0x4,%esp
  802099:	68 e4 2a 80 00       	push   $0x802ae4
  80209e:	6a 21                	push   $0x21
  8020a0:	68 46 2b 80 00       	push   $0x802b46
  8020a5:	e8 01 e2 ff ff       	call   8002ab <_panic>
        panic("set_pgfault_handler:sys_env_set_pgfault_upcall failed");
  8020aa:	83 ec 04             	sub    $0x4,%esp
  8020ad:	68 10 2b 80 00       	push   $0x802b10
  8020b2:	6a 27                	push   $0x27
  8020b4:	68 46 2b 80 00       	push   $0x802b46
  8020b9:	e8 ed e1 ff ff       	call   8002ab <_panic>

008020be <_pgfault_upcall>:

.text
.globl _pgfault_upcall
_pgfault_upcall:
	// Call the C page fault handler.
	pushl %esp			// function argument: pointer to UTF
  8020be:	54                   	push   %esp
	movl _pgfault_handler, %eax
  8020bf:	a1 00 60 80 00       	mov    0x806000,%eax
	call *%eax
  8020c4:	ff d0                	call   *%eax
	addl $4, %esp			// pop function argument
  8020c6:	83 c4 04             	add    $0x4,%esp
	// may find that you have to rearrange your code in non-obvious
	// ways as registers become unavailable as scratch space.
	//
	// LAB 4: Your code here.
	//首先把此时的eip指针下移48个字节因为UTrapFrame的大小是48个字节
	movl 48(%esp), %ebp
  8020c9:	8b 6c 24 30          	mov    0x30(%esp),%ebp
    subl $4, %ebp		// UTrapFrame.utf_esp - 4 and store back 这里是由于之前预留了4个字节。
  8020cd:	83 ed 04             	sub    $0x4,%ebp
    movl %ebp, 48(%esp)	// 返回上一次的esp位置。
  8020d0:	89 6c 24 30          	mov    %ebp,0x30(%esp)

	// Restore the trap-time registers.  After you do this, you
	// can no longer modify any general-purpose registers.
	// LAB 4: Your code here.
	movl 40(%esp), %eax 
  8020d4:	8b 44 24 28          	mov    0x28(%esp),%eax
    movl %eax, (%ebp)
  8020d8:	89 45 00             	mov    %eax,0x0(%ebp)

	// Restore eflags from the stack.  After you do this, you can
	// no longer use arithmetic operations or anything else that
	// modifies eflags.
	// LAB 4: Your code here.
	addl $0x8, %esp         // Set %esp to the end of struct PushRegs
  8020db:	83 c4 08             	add    $0x8,%esp
	popal                   // Restore the trap-time registers.(struct PushRegs)
  8020de:	61                   	popa   

	// Switch back to the adjusted trap-time stack.
	// LAB 4: Your code here.
	addl $0x4, %esp         // now we are located at trap-time eip,so we have to increment %esp with 4.【跳过eip】
  8020df:	83 c4 04             	add    $0x4,%esp
	popfl                   // Restore eflags register.	【pop eflags】
  8020e2:	9d                   	popf   
	popl %esp               // Just restore the adjusted trap-time stack pointer.
  8020e3:	5c                   	pop    %esp
							// 恢复esp

	// Return to re-execute the instruction that faulted.
	// LAB 4: Your code here.
	ret                     // We are now on the trap-time stack,since we have saved trap-time eip above trap-time esp,ret instruction will pop this trap-time eip to register %eip which known as PC at this time.Thus,we can return to re-execute the instruction that faulted.
  8020e4:	c3                   	ret    

008020e5 <ipc_recv>:
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value, since that's
//   a perfectly valid place to map a page.)
int32_t
ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
{
  8020e5:	f3 0f 1e fb          	endbr32 
  8020e9:	55                   	push   %ebp
  8020ea:	89 e5                	mov    %esp,%ebp
  8020ec:	56                   	push   %esi
  8020ed:	53                   	push   %ebx
  8020ee:	8b 75 08             	mov    0x8(%ebp),%esi
  8020f1:	8b 45 0c             	mov    0xc(%ebp),%eax
  8020f4:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// LAB 4: Your code here.
	int error;
	if(!pg)pg = (void *)UTOP; // 如果设置为UTOP，这个值其实可以比UTOP大，设置为这个值认为pg无效了，不会进行页面传递【共享页面的设置】，而是只进行值value的传递。
  8020f7:	85 c0                	test   %eax,%eax
  8020f9:	ba 00 00 c0 ee       	mov    $0xeec00000,%edx
  8020fe:	0f 44 c2             	cmove  %edx,%eax
	if((error = sys_ipc_recv(pg)) < 0){
  802101:	83 ec 0c             	sub    $0xc,%esp
  802104:	50                   	push   %eax
  802105:	e8 6f ee ff ff       	call   800f79 <sys_ipc_recv>
  80210a:	83 c4 10             	add    $0x10,%esp
  80210d:	85 c0                	test   %eax,%eax
  80210f:	78 3f                	js     802150 <ipc_recv+0x6b>
		if(from_env_store)*from_env_store = 0;
		if(perm_store)*perm_store = 0;
		return error;
	}

	thisenv = &envs[ENVX(sys_getenvid())]; // for lab4's challenge sfork().
  802111:	e8 51 ec ff ff       	call   800d67 <sys_getenvid>
  802116:	25 ff 03 00 00       	and    $0x3ff,%eax
  80211b:	6b d0 7c             	imul   $0x7c,%eax,%edx
  80211e:	81 c2 00 00 c0 ee    	add    $0xeec00000,%edx
  802124:	89 15 04 40 80 00    	mov    %edx,0x804004

	if(from_env_store)*from_env_store = thisenv->env_ipc_from;
  80212a:	85 f6                	test   %esi,%esi
  80212c:	74 05                	je     802133 <ipc_recv+0x4e>
  80212e:	8b 42 74             	mov    0x74(%edx),%eax
  802131:	89 06                	mov    %eax,(%esi)
	if(perm_store)*perm_store = thisenv->env_ipc_perm;
  802133:	85 db                	test   %ebx,%ebx
  802135:	74 0a                	je     802141 <ipc_recv+0x5c>
  802137:	a1 04 40 80 00       	mov    0x804004,%eax
  80213c:	8b 40 78             	mov    0x78(%eax),%eax
  80213f:	89 03                	mov    %eax,(%ebx)
	return thisenv->env_ipc_value;
  802141:	a1 04 40 80 00       	mov    0x804004,%eax
  802146:	8b 40 70             	mov    0x70(%eax),%eax
}
  802149:	8d 65 f8             	lea    -0x8(%ebp),%esp
  80214c:	5b                   	pop    %ebx
  80214d:	5e                   	pop    %esi
  80214e:	5d                   	pop    %ebp
  80214f:	c3                   	ret    
		if(from_env_store)*from_env_store = 0;
  802150:	85 f6                	test   %esi,%esi
  802152:	74 06                	je     80215a <ipc_recv+0x75>
  802154:	c7 06 00 00 00 00    	movl   $0x0,(%esi)
		if(perm_store)*perm_store = 0;
  80215a:	85 db                	test   %ebx,%ebx
  80215c:	74 eb                	je     802149 <ipc_recv+0x64>
  80215e:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  802164:	eb e3                	jmp    802149 <ipc_recv+0x64>

00802166 <ipc_send>:
//   Use sys_yield() to be CPU-friendly.
//   If 'pg' is null, pass sys_ipc_try_send a value that it will understand
//   as meaning "no page".  (Zero is not the right value.)
void
ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
{
  802166:	f3 0f 1e fb          	endbr32 
  80216a:	55                   	push   %ebp
  80216b:	89 e5                	mov    %esp,%ebp
  80216d:	57                   	push   %edi
  80216e:	56                   	push   %esi
  80216f:	53                   	push   %ebx
  802170:	83 ec 0c             	sub    $0xc,%esp
  802173:	8b 7d 08             	mov    0x8(%ebp),%edi
  802176:	8b 75 0c             	mov    0xc(%ebp),%esi
  802179:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// LAB 4: Your code here.
	if(!pg)pg = (void *)UTOP; // 不会进行页面共享，只会sending message。
  80217c:	85 db                	test   %ebx,%ebx
  80217e:	b8 00 00 c0 ee       	mov    $0xeec00000,%eax
  802183:	0f 44 d8             	cmove  %eax,%ebx
	int error;
	// Keep trying until it succeeds.
	while((error = sys_ipc_try_send(to_env, val, pg, perm)) < 0){
  802186:	ff 75 14             	pushl  0x14(%ebp)
  802189:	53                   	push   %ebx
  80218a:	56                   	push   %esi
  80218b:	57                   	push   %edi
  80218c:	e8 c1 ed ff ff       	call   800f52 <sys_ipc_try_send>
  802191:	83 c4 10             	add    $0x10,%esp
  802194:	85 c0                	test   %eax,%eax
  802196:	79 1e                	jns    8021b6 <ipc_send+0x50>
        //如果error是没有接收者，那么就会继续尝试send
		if(error != -E_IPC_NOT_RECV){
  802198:	83 f8 f9             	cmp    $0xfffffff9,%eax
  80219b:	75 07                	jne    8021a4 <ipc_send+0x3e>
			panic("sys_ipc_try_send:%e", error);
		}
        //但是不是一味的占用cpu，而是尝试一次就释放CPU，等待再次被调度，才会重新send，寻找receiver。
		sys_yield(); // To be CPU-friendly.
  80219d:	e8 e8 eb ff ff       	call   800d8a <sys_yield>
  8021a2:	eb e2                	jmp    802186 <ipc_send+0x20>
			panic("sys_ipc_try_send:%e", error);
  8021a4:	50                   	push   %eax
  8021a5:	68 54 2b 80 00       	push   $0x802b54
  8021aa:	6a 3b                	push   $0x3b
  8021ac:	68 68 2b 80 00       	push   $0x802b68
  8021b1:	e8 f5 e0 ff ff       	call   8002ab <_panic>
	}
}
  8021b6:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8021b9:	5b                   	pop    %ebx
  8021ba:	5e                   	pop    %esi
  8021bb:	5f                   	pop    %edi
  8021bc:	5d                   	pop    %ebp
  8021bd:	c3                   	ret    

008021be <ipc_find_env>:
// Find the first environment of the given type.  We'll use this to
// find special environments.
// Returns 0 if no such environment exists.
envid_t
ipc_find_env(enum EnvType type)
{
  8021be:	f3 0f 1e fb          	endbr32 
  8021c2:	55                   	push   %ebp
  8021c3:	89 e5                	mov    %esp,%ebp
  8021c5:	8b 4d 08             	mov    0x8(%ebp),%ecx
	int i;
	for (i = 0; i < NENV; i++)
  8021c8:	b8 00 00 00 00       	mov    $0x0,%eax
		if (envs[i].env_type == type)
  8021cd:	6b d0 7c             	imul   $0x7c,%eax,%edx
  8021d0:	81 c2 00 00 c0 ee    	add    $0xeec00000,%edx
  8021d6:	8b 52 50             	mov    0x50(%edx),%edx
  8021d9:	39 ca                	cmp    %ecx,%edx
  8021db:	74 11                	je     8021ee <ipc_find_env+0x30>
	for (i = 0; i < NENV; i++)
  8021dd:	83 c0 01             	add    $0x1,%eax
  8021e0:	3d 00 04 00 00       	cmp    $0x400,%eax
  8021e5:	75 e6                	jne    8021cd <ipc_find_env+0xf>
			return envs[i].env_id;
	return 0;
  8021e7:	b8 00 00 00 00       	mov    $0x0,%eax
  8021ec:	eb 0b                	jmp    8021f9 <ipc_find_env+0x3b>
			return envs[i].env_id;
  8021ee:	6b c0 7c             	imul   $0x7c,%eax,%eax
  8021f1:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  8021f6:	8b 40 48             	mov    0x48(%eax),%eax
}
  8021f9:	5d                   	pop    %ebp
  8021fa:	c3                   	ret    

008021fb <pageref>:
#include <inc/lib.h>

int
pageref(void *v)
{
  8021fb:	f3 0f 1e fb          	endbr32 
  8021ff:	55                   	push   %ebp
  802200:	89 e5                	mov    %esp,%ebp
  802202:	8b 45 08             	mov    0x8(%ebp),%eax
	pte_t pte;

	if (!(uvpd[PDX(v)] & PTE_P))
  802205:	89 c2                	mov    %eax,%edx
  802207:	c1 ea 16             	shr    $0x16,%edx
  80220a:	8b 0c 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%ecx
		return 0;
  802211:	ba 00 00 00 00       	mov    $0x0,%edx
	if (!(uvpd[PDX(v)] & PTE_P))
  802216:	f6 c1 01             	test   $0x1,%cl
  802219:	74 1c                	je     802237 <pageref+0x3c>
	pte = uvpt[PGNUM(v)];
  80221b:	c1 e8 0c             	shr    $0xc,%eax
  80221e:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
	if (!(pte & PTE_P))
  802225:	a8 01                	test   $0x1,%al
  802227:	74 0e                	je     802237 <pageref+0x3c>
		return 0;
	return pages[PGNUM(pte)].pp_ref;
  802229:	c1 e8 0c             	shr    $0xc,%eax
  80222c:	0f b7 14 c5 04 00 00 	movzwl -0x10fffffc(,%eax,8),%edx
  802233:	ef 
  802234:	0f b7 d2             	movzwl %dx,%edx
}
  802237:	89 d0                	mov    %edx,%eax
  802239:	5d                   	pop    %ebp
  80223a:	c3                   	ret    
  80223b:	66 90                	xchg   %ax,%ax
  80223d:	66 90                	xchg   %ax,%ax
  80223f:	90                   	nop

00802240 <__udivdi3>:
  802240:	f3 0f 1e fb          	endbr32 
  802244:	55                   	push   %ebp
  802245:	57                   	push   %edi
  802246:	56                   	push   %esi
  802247:	53                   	push   %ebx
  802248:	83 ec 1c             	sub    $0x1c,%esp
  80224b:	8b 54 24 3c          	mov    0x3c(%esp),%edx
  80224f:	8b 6c 24 30          	mov    0x30(%esp),%ebp
  802253:	8b 74 24 34          	mov    0x34(%esp),%esi
  802257:	8b 5c 24 38          	mov    0x38(%esp),%ebx
  80225b:	85 d2                	test   %edx,%edx
  80225d:	75 19                	jne    802278 <__udivdi3+0x38>
  80225f:	39 f3                	cmp    %esi,%ebx
  802261:	76 4d                	jbe    8022b0 <__udivdi3+0x70>
  802263:	31 ff                	xor    %edi,%edi
  802265:	89 e8                	mov    %ebp,%eax
  802267:	89 f2                	mov    %esi,%edx
  802269:	f7 f3                	div    %ebx
  80226b:	89 fa                	mov    %edi,%edx
  80226d:	83 c4 1c             	add    $0x1c,%esp
  802270:	5b                   	pop    %ebx
  802271:	5e                   	pop    %esi
  802272:	5f                   	pop    %edi
  802273:	5d                   	pop    %ebp
  802274:	c3                   	ret    
  802275:	8d 76 00             	lea    0x0(%esi),%esi
  802278:	39 f2                	cmp    %esi,%edx
  80227a:	76 14                	jbe    802290 <__udivdi3+0x50>
  80227c:	31 ff                	xor    %edi,%edi
  80227e:	31 c0                	xor    %eax,%eax
  802280:	89 fa                	mov    %edi,%edx
  802282:	83 c4 1c             	add    $0x1c,%esp
  802285:	5b                   	pop    %ebx
  802286:	5e                   	pop    %esi
  802287:	5f                   	pop    %edi
  802288:	5d                   	pop    %ebp
  802289:	c3                   	ret    
  80228a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  802290:	0f bd fa             	bsr    %edx,%edi
  802293:	83 f7 1f             	xor    $0x1f,%edi
  802296:	75 48                	jne    8022e0 <__udivdi3+0xa0>
  802298:	39 f2                	cmp    %esi,%edx
  80229a:	72 06                	jb     8022a2 <__udivdi3+0x62>
  80229c:	31 c0                	xor    %eax,%eax
  80229e:	39 eb                	cmp    %ebp,%ebx
  8022a0:	77 de                	ja     802280 <__udivdi3+0x40>
  8022a2:	b8 01 00 00 00       	mov    $0x1,%eax
  8022a7:	eb d7                	jmp    802280 <__udivdi3+0x40>
  8022a9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  8022b0:	89 d9                	mov    %ebx,%ecx
  8022b2:	85 db                	test   %ebx,%ebx
  8022b4:	75 0b                	jne    8022c1 <__udivdi3+0x81>
  8022b6:	b8 01 00 00 00       	mov    $0x1,%eax
  8022bb:	31 d2                	xor    %edx,%edx
  8022bd:	f7 f3                	div    %ebx
  8022bf:	89 c1                	mov    %eax,%ecx
  8022c1:	31 d2                	xor    %edx,%edx
  8022c3:	89 f0                	mov    %esi,%eax
  8022c5:	f7 f1                	div    %ecx
  8022c7:	89 c6                	mov    %eax,%esi
  8022c9:	89 e8                	mov    %ebp,%eax
  8022cb:	89 f7                	mov    %esi,%edi
  8022cd:	f7 f1                	div    %ecx
  8022cf:	89 fa                	mov    %edi,%edx
  8022d1:	83 c4 1c             	add    $0x1c,%esp
  8022d4:	5b                   	pop    %ebx
  8022d5:	5e                   	pop    %esi
  8022d6:	5f                   	pop    %edi
  8022d7:	5d                   	pop    %ebp
  8022d8:	c3                   	ret    
  8022d9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  8022e0:	89 f9                	mov    %edi,%ecx
  8022e2:	b8 20 00 00 00       	mov    $0x20,%eax
  8022e7:	29 f8                	sub    %edi,%eax
  8022e9:	d3 e2                	shl    %cl,%edx
  8022eb:	89 54 24 08          	mov    %edx,0x8(%esp)
  8022ef:	89 c1                	mov    %eax,%ecx
  8022f1:	89 da                	mov    %ebx,%edx
  8022f3:	d3 ea                	shr    %cl,%edx
  8022f5:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  8022f9:	09 d1                	or     %edx,%ecx
  8022fb:	89 f2                	mov    %esi,%edx
  8022fd:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  802301:	89 f9                	mov    %edi,%ecx
  802303:	d3 e3                	shl    %cl,%ebx
  802305:	89 c1                	mov    %eax,%ecx
  802307:	d3 ea                	shr    %cl,%edx
  802309:	89 f9                	mov    %edi,%ecx
  80230b:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  80230f:	89 eb                	mov    %ebp,%ebx
  802311:	d3 e6                	shl    %cl,%esi
  802313:	89 c1                	mov    %eax,%ecx
  802315:	d3 eb                	shr    %cl,%ebx
  802317:	09 de                	or     %ebx,%esi
  802319:	89 f0                	mov    %esi,%eax
  80231b:	f7 74 24 08          	divl   0x8(%esp)
  80231f:	89 d6                	mov    %edx,%esi
  802321:	89 c3                	mov    %eax,%ebx
  802323:	f7 64 24 0c          	mull   0xc(%esp)
  802327:	39 d6                	cmp    %edx,%esi
  802329:	72 15                	jb     802340 <__udivdi3+0x100>
  80232b:	89 f9                	mov    %edi,%ecx
  80232d:	d3 e5                	shl    %cl,%ebp
  80232f:	39 c5                	cmp    %eax,%ebp
  802331:	73 04                	jae    802337 <__udivdi3+0xf7>
  802333:	39 d6                	cmp    %edx,%esi
  802335:	74 09                	je     802340 <__udivdi3+0x100>
  802337:	89 d8                	mov    %ebx,%eax
  802339:	31 ff                	xor    %edi,%edi
  80233b:	e9 40 ff ff ff       	jmp    802280 <__udivdi3+0x40>
  802340:	8d 43 ff             	lea    -0x1(%ebx),%eax
  802343:	31 ff                	xor    %edi,%edi
  802345:	e9 36 ff ff ff       	jmp    802280 <__udivdi3+0x40>
  80234a:	66 90                	xchg   %ax,%ax
  80234c:	66 90                	xchg   %ax,%ax
  80234e:	66 90                	xchg   %ax,%ax

00802350 <__umoddi3>:
  802350:	f3 0f 1e fb          	endbr32 
  802354:	55                   	push   %ebp
  802355:	57                   	push   %edi
  802356:	56                   	push   %esi
  802357:	53                   	push   %ebx
  802358:	83 ec 1c             	sub    $0x1c,%esp
  80235b:	8b 44 24 3c          	mov    0x3c(%esp),%eax
  80235f:	8b 74 24 30          	mov    0x30(%esp),%esi
  802363:	8b 5c 24 34          	mov    0x34(%esp),%ebx
  802367:	8b 7c 24 38          	mov    0x38(%esp),%edi
  80236b:	85 c0                	test   %eax,%eax
  80236d:	75 19                	jne    802388 <__umoddi3+0x38>
  80236f:	39 df                	cmp    %ebx,%edi
  802371:	76 5d                	jbe    8023d0 <__umoddi3+0x80>
  802373:	89 f0                	mov    %esi,%eax
  802375:	89 da                	mov    %ebx,%edx
  802377:	f7 f7                	div    %edi
  802379:	89 d0                	mov    %edx,%eax
  80237b:	31 d2                	xor    %edx,%edx
  80237d:	83 c4 1c             	add    $0x1c,%esp
  802380:	5b                   	pop    %ebx
  802381:	5e                   	pop    %esi
  802382:	5f                   	pop    %edi
  802383:	5d                   	pop    %ebp
  802384:	c3                   	ret    
  802385:	8d 76 00             	lea    0x0(%esi),%esi
  802388:	89 f2                	mov    %esi,%edx
  80238a:	39 d8                	cmp    %ebx,%eax
  80238c:	76 12                	jbe    8023a0 <__umoddi3+0x50>
  80238e:	89 f0                	mov    %esi,%eax
  802390:	89 da                	mov    %ebx,%edx
  802392:	83 c4 1c             	add    $0x1c,%esp
  802395:	5b                   	pop    %ebx
  802396:	5e                   	pop    %esi
  802397:	5f                   	pop    %edi
  802398:	5d                   	pop    %ebp
  802399:	c3                   	ret    
  80239a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  8023a0:	0f bd e8             	bsr    %eax,%ebp
  8023a3:	83 f5 1f             	xor    $0x1f,%ebp
  8023a6:	75 50                	jne    8023f8 <__umoddi3+0xa8>
  8023a8:	39 d8                	cmp    %ebx,%eax
  8023aa:	0f 82 e0 00 00 00    	jb     802490 <__umoddi3+0x140>
  8023b0:	89 d9                	mov    %ebx,%ecx
  8023b2:	39 f7                	cmp    %esi,%edi
  8023b4:	0f 86 d6 00 00 00    	jbe    802490 <__umoddi3+0x140>
  8023ba:	89 d0                	mov    %edx,%eax
  8023bc:	89 ca                	mov    %ecx,%edx
  8023be:	83 c4 1c             	add    $0x1c,%esp
  8023c1:	5b                   	pop    %ebx
  8023c2:	5e                   	pop    %esi
  8023c3:	5f                   	pop    %edi
  8023c4:	5d                   	pop    %ebp
  8023c5:	c3                   	ret    
  8023c6:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  8023cd:	8d 76 00             	lea    0x0(%esi),%esi
  8023d0:	89 fd                	mov    %edi,%ebp
  8023d2:	85 ff                	test   %edi,%edi
  8023d4:	75 0b                	jne    8023e1 <__umoddi3+0x91>
  8023d6:	b8 01 00 00 00       	mov    $0x1,%eax
  8023db:	31 d2                	xor    %edx,%edx
  8023dd:	f7 f7                	div    %edi
  8023df:	89 c5                	mov    %eax,%ebp
  8023e1:	89 d8                	mov    %ebx,%eax
  8023e3:	31 d2                	xor    %edx,%edx
  8023e5:	f7 f5                	div    %ebp
  8023e7:	89 f0                	mov    %esi,%eax
  8023e9:	f7 f5                	div    %ebp
  8023eb:	89 d0                	mov    %edx,%eax
  8023ed:	31 d2                	xor    %edx,%edx
  8023ef:	eb 8c                	jmp    80237d <__umoddi3+0x2d>
  8023f1:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  8023f8:	89 e9                	mov    %ebp,%ecx
  8023fa:	ba 20 00 00 00       	mov    $0x20,%edx
  8023ff:	29 ea                	sub    %ebp,%edx
  802401:	d3 e0                	shl    %cl,%eax
  802403:	89 44 24 08          	mov    %eax,0x8(%esp)
  802407:	89 d1                	mov    %edx,%ecx
  802409:	89 f8                	mov    %edi,%eax
  80240b:	d3 e8                	shr    %cl,%eax
  80240d:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  802411:	89 54 24 04          	mov    %edx,0x4(%esp)
  802415:	8b 54 24 04          	mov    0x4(%esp),%edx
  802419:	09 c1                	or     %eax,%ecx
  80241b:	89 d8                	mov    %ebx,%eax
  80241d:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  802421:	89 e9                	mov    %ebp,%ecx
  802423:	d3 e7                	shl    %cl,%edi
  802425:	89 d1                	mov    %edx,%ecx
  802427:	d3 e8                	shr    %cl,%eax
  802429:	89 e9                	mov    %ebp,%ecx
  80242b:	89 7c 24 0c          	mov    %edi,0xc(%esp)
  80242f:	d3 e3                	shl    %cl,%ebx
  802431:	89 c7                	mov    %eax,%edi
  802433:	89 d1                	mov    %edx,%ecx
  802435:	89 f0                	mov    %esi,%eax
  802437:	d3 e8                	shr    %cl,%eax
  802439:	89 e9                	mov    %ebp,%ecx
  80243b:	89 fa                	mov    %edi,%edx
  80243d:	d3 e6                	shl    %cl,%esi
  80243f:	09 d8                	or     %ebx,%eax
  802441:	f7 74 24 08          	divl   0x8(%esp)
  802445:	89 d1                	mov    %edx,%ecx
  802447:	89 f3                	mov    %esi,%ebx
  802449:	f7 64 24 0c          	mull   0xc(%esp)
  80244d:	89 c6                	mov    %eax,%esi
  80244f:	89 d7                	mov    %edx,%edi
  802451:	39 d1                	cmp    %edx,%ecx
  802453:	72 06                	jb     80245b <__umoddi3+0x10b>
  802455:	75 10                	jne    802467 <__umoddi3+0x117>
  802457:	39 c3                	cmp    %eax,%ebx
  802459:	73 0c                	jae    802467 <__umoddi3+0x117>
  80245b:	2b 44 24 0c          	sub    0xc(%esp),%eax
  80245f:	1b 54 24 08          	sbb    0x8(%esp),%edx
  802463:	89 d7                	mov    %edx,%edi
  802465:	89 c6                	mov    %eax,%esi
  802467:	89 ca                	mov    %ecx,%edx
  802469:	0f b6 4c 24 04       	movzbl 0x4(%esp),%ecx
  80246e:	29 f3                	sub    %esi,%ebx
  802470:	19 fa                	sbb    %edi,%edx
  802472:	89 d0                	mov    %edx,%eax
  802474:	d3 e0                	shl    %cl,%eax
  802476:	89 e9                	mov    %ebp,%ecx
  802478:	d3 eb                	shr    %cl,%ebx
  80247a:	d3 ea                	shr    %cl,%edx
  80247c:	09 d8                	or     %ebx,%eax
  80247e:	83 c4 1c             	add    $0x1c,%esp
  802481:	5b                   	pop    %ebx
  802482:	5e                   	pop    %esi
  802483:	5f                   	pop    %edi
  802484:	5d                   	pop    %ebp
  802485:	c3                   	ret    
  802486:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  80248d:	8d 76 00             	lea    0x0(%esi),%esi
  802490:	29 fe                	sub    %edi,%esi
  802492:	19 c3                	sbb    %eax,%ebx
  802494:	89 f2                	mov    %esi,%edx
  802496:	89 d9                	mov    %ebx,%ecx
  802498:	e9 1d ff ff ff       	jmp    8023ba <__umoddi3+0x6a>
